121 lines
3.8 KiB
YAML
121 lines
3.8 KiB
YAML
name: Release
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
jobs:
|
|
test:
|
|
name: Lint and test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version-file: go.mod
|
|
- name: Lint
|
|
uses: golangci/golangci-lint-action@v9
|
|
with:
|
|
install-mode: goinstall
|
|
version: v2.6.1
|
|
- name: Test
|
|
run: go test ./...
|
|
release-please:
|
|
name: Run Release Please
|
|
runs-on: ubuntu-latest
|
|
needs: [test]
|
|
outputs:
|
|
release_created: ${{ steps.release.outputs.release_created }}
|
|
tag_name: ${{ steps.release.outputs.tag_name }}
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
- name: Setup Release Please
|
|
uses: google-github-actions/release-please-action@v2
|
|
id: release
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
release-type: simple
|
|
changelog-path: CHANGELOG.md
|
|
package-name: gonic
|
|
build-binaries:
|
|
name: Build binaries
|
|
runs-on: ubuntu-latest
|
|
needs: [release-please]
|
|
if: ${{ needs.release-please.outputs.release_created }}
|
|
strategy:
|
|
matrix:
|
|
os: [linux, windows, darwin]
|
|
arch: [amd64, arm64, 386]
|
|
exclude:
|
|
- os: darwin
|
|
arch: 386
|
|
# https://github.com/natefinch/npipe/issues/33 (required by mpvipc)
|
|
- os: windows
|
|
arch: arm64
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version-file: go.mod
|
|
- name: Build
|
|
run: |
|
|
set -e
|
|
CGO_ENABLED=0 GOOS="${{ matrix.os }}" GOARCH="${{ matrix.arch }}" go build -o out/ ./cmd/...
|
|
[[ "${{ matrix.os }}" = "windows" ]] && suff=".exe"
|
|
cd out/
|
|
for p in *; do
|
|
mv "$p" "${p%.*}-${{ matrix.os }}-${{ matrix.arch }}-${{ needs.release-please.outputs.tag_name }}$suff"
|
|
done
|
|
cd -
|
|
- name: Upload
|
|
uses: svenstaro/upload-release-action@v2
|
|
with:
|
|
repo_token: ${{ secrets.CR_PAT }}
|
|
file: out/*
|
|
file_glob: true
|
|
tag: ${{ needs.release-please.outputs.tag_name }}
|
|
build-docker:
|
|
name: Build, tag, and publish Docker image
|
|
runs-on: ubuntu-latest
|
|
needs: [release-please]
|
|
if: ${{ needs.release-please.outputs.release_created }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Setup Docker Buildx
|
|
uses: docker/setup-buildx-action@v1
|
|
- name: Login into DockerHub
|
|
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
|
|
- name: Login into GitHub Container Registry
|
|
run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
|
- name: Build and Push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
|
|
push: true
|
|
tags: |
|
|
ghcr.io/${{ github.repository }}:${{ needs.release-please.outputs.tag_name }}
|
|
ghcr.io/${{ github.repository }}:latest
|
|
${{ github.repository }}:${{ needs.release-please.outputs.tag_name }}
|
|
${{ github.repository }}:latest
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
notify-irc:
|
|
needs: [release-please]
|
|
name: Notify IRC
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
- name: Notify
|
|
run: |
|
|
set +x e
|
|
git log -1 --pretty="push to master (@%an) %s" | curl "${{ secrets.IRC_NOTIFY_URL }}" -F target=#gonic -F message=@- >/dev/null 2>&1
|
|
exit 0
|