Skip to content

feat: tag git sha

feat: tag git sha #10

Workflow file for this run

name: Release Crunchy
on:
push:
branches:
- main
tags:
- "v*"
workflow_dispatch:
jobs:
build:
name: Build binaries
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
- goos: darwin
goarch: arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
set -euo pipefail
binary="crunchy-${GOOS}-${GOARCH}"
mkdir -p dist
go build -o "dist/$binary" .
- name: Generate checksum
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
set -euo pipefail
cd dist
binary="crunchy-${GOOS}-${GOARCH}"
sha="${binary}.sha256"
sha256sum "$binary" > "$sha"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: crunchy-${{ matrix.goos }}-${{ matrix.goarch }}
path: |
dist/crunchy-${{ matrix.goos }}-${{ matrix.goarch }}
dist/crunchy-${{ matrix.goos }}-${{ matrix.goarch }}.sha256
release:
name: Publish release
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure git user
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Determine release tag
id: release_tag
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
else
echo "tag=latest" >> "$GITHUB_OUTPUT"
fi
- name: Update latest tag
env:
COMMIT_SHA: ${{ github.sha }}
run: |
set -euo pipefail
git fetch --tags
git tag -d latest 2>/dev/null || true
git push origin :refs/tags/latest || true
git tag latest "$COMMIT_SHA"
git push origin latest --force
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: release
- name: Publish GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.release_tag.outputs.tag }}
target_commitish: ${{ github.sha }}
name: ${{ steps.release_tag.outputs.tag == 'latest' && 'Latest' || steps.release_tag.outputs.tag }}
make_latest: true
files: release/**/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}