webhookd/.github/workflows/build.yml

102 lines
2.7 KiB
YAML
Raw Normal View History

2021-06-18 08:43:38 +00:00
name: Build
on:
push:
branches: [ master ]
2023-10-04 19:19:40 +00:00
tags: [ 'v*' ]
2021-06-18 08:43:38 +00:00
pull_request:
branches: [ master ]
jobs:
2023-10-04 19:19:40 +00:00
# Build and test project
2021-06-18 08:43:38 +00:00
build:
runs-on: ubuntu-latest
steps:
2023-10-04 19:19:40 +00:00
- uses: actions/checkout@v4
2021-06-18 08:43:38 +00:00
with:
submodules: recursive
2023-10-04 19:19:40 +00:00
- uses: actions/setup-go@v4
2021-06-18 08:43:38 +00:00
with:
2023-10-04 19:19:40 +00:00
go-version: stable
- run: make build test
# Create project release if tagged
2023-10-03 20:54:47 +00:00
release:
runs-on: ubuntu-latest
2023-10-04 19:19:40 +00:00
if: startsWith(github.ref, 'refs/tags/')
2023-10-03 20:54:47 +00:00
needs: build
steps:
2023-10-04 19:19:40 +00:00
- uses: actions/checkout@v4
2023-10-03 21:01:04 +00:00
with:
submodules: recursive
2023-10-04 19:19:40 +00:00
- uses: actions/setup-go@v4
with:
go-version: stable
- uses: actions/setup-node@v3
with:
node-version: current
- run: npm install -g standard-changelog
- run: make distribution
- name: get CHANGELOG
2023-10-03 20:54:47 +00:00
id: changelog
2023-10-04 19:19:40 +00:00
uses: requarks/changelog-action@v1
with:
token: ${{ github.token }}
tag: ${{ github.ref_name }}
- uses: softprops/action-gh-release@v1
with:
body: ${{ steps.changelog.outputs.changes }}
2021-06-18 08:43:38 +00:00
files: |
release/webhookd-linux-amd64.tgz
release/webhookd-linux-arm64.tgz
release/webhookd-linux-arm.tgz
release/webhookd-darwin-amd64.tgz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2023-10-04 19:19:40 +00:00
# Publish Docker image
publish:
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
include:
- target: slim
suffix: ''
- target: distrib
suffix: -distrib
2023-10-04 19:19:40 +00:00
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
2023-10-05 18:15:26 +00:00
images: ncarlier/webhookd
flavor: suffix=${{ matrix.suffix }}
2023-10-04 19:19:40 +00:00
tags: |
type=edge
type=semver,pattern={{major}}
type=semver,pattern={{version}}
2023-10-04 19:19:40 +00:00
- uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: arm64,arm
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1
if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and push Docker image (${{ matrix.target }})
uses: docker/build-push-action@v2
2023-10-04 19:19:40 +00:00
with:
context: .
target: ${{ matrix.target }}
2023-10-04 19:19:40 +00:00
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}