Skip to content

chore: add github workflow for repository housekeeping #9

chore: add github workflow for repository housekeeping

chore: add github workflow for repository housekeeping #9

Workflow file for this run

name: release
on:
push:
branches:
- main
jobs:
tag:
name: Create version tag
runs-on: ubuntu-latest
outputs:
changelog: ${{ steps.tag.outputs.changelog }}
tag: ${{ steps.tag.outputs.new_tag }}
version: ${{ steps.tag.outputs.new_version }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Bump version and tag
uses: mathieudutour/github-tag-action@v6.1
id: tag
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
containers:
name: Create containers
runs-on: ubuntu-latest
needs: tag
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Go
uses: WillAbides/setup-go-faster@v1.9.0
with:
go-version: 1.19
- name: Setup Ko
uses: imjasonh/setup-ko@v0.6
with:
version: v0.11.2
- name: Build and push containers
env:
VERSION: ${{ needs.tag.outputs.tag }}
run: |
ko build \
--platform=linux/amd64,linux/arm/v7,linux/arm64 \
--bare \
--tags=latest,${{ needs.tag.outputs.tag }} \
--image-label="org.opencontainers.image.title=${{ github.event.repository.name }}" \
--image-label="org.opencontainers.image.description=${{ github.event.repository.description }}" \
--image-label="org.opencontainers.image.source=https://github.com/${{ github.repository }}" \
--image-label="org.opencontainers.image.version=${{ needs.tag.outputs.tag }}" \
--image-label="org.opencontainers.image.revision=${{ github.sha }}" \
./
binaries:
name: Create binaries
runs-on: ubuntu-latest
needs: tag
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: ["386", amd64, arm, arm64]
exclude:
- goos: windows
goarch: "386"
- goos: windows
goarch: arm
- goos: windows
goarch: arm64
- goos: darwin
goarch: "386"
- goos: darwin
goarch: arm
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Go
uses: WillAbides/setup-go-faster@v1.9.0
with:
go-version: '1.19'
- name: Build binaries
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
BINARY: ${{ github.event.repository.name }}-${{ needs.tag.outputs.tag }}-${{ matrix.goos }}-${{ matrix.goarch }}
VERSIONFLAG: -X 'main.Version=${{ needs.tag.outputs.tag }}'
run: |
go build -ldflags="${VERSIONFLAG}" -o ${BINARY}
- name: Save artifact
uses: actions/upload-artifact@v3
with:
name: binaries
path: ${{ github.event.repository.name }}-v*-*-*
retention-days: 1
release:
name: Create release
runs-on: ubuntu-latest
needs:
- tag
- binaries
- containers
steps:
- name: Fetch binaries
uses: actions/download-artifact@v3
with:
name: binaries
- name: Create checksums
run: |
sha256sum ${{ github.event.repository.name }}-v*-*-* | tee ${{ github.event.repository.name }}-${{ needs.tag.outputs.tag }}.sha256
- name: Create release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.tag.outputs.tag }}
name: Release ${{ needs.tag.outputs.version }}
body: |
Changes in this release:
${{ needs.tag.outputs.changelog }}
Docker image: ghcr.io/${{ github.repository }}:${{ needs.tag.outputs.tag }}
files: ${{ github.event.repository.name }}-v*-*-*,${{ github.event.repository.name }}-*.sha256