Skip to content

ci: fix order

ci: fix order #6

Workflow file for this run

name: Release Crunchy
on:
push:
branches:
- main
tags:
- "v*"
workflow_dispatch:
jobs:
retag:
name: Update latest tag
needs: release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
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: Move latest tag
env:
COMMIT_SHA: ${{ github.sha }}
run: |
set -euo pipefail
if git rev-parse latest >/dev/null 2>&1; then
git tag -d latest
fi
git push origin :refs/tags/latest || true
git tag latest "$COMMIT_SHA"
git push origin latest --force
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
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: release
- name: Publish GitHub Release
uses: softprops/action-gh-release@v1
with:
files: release/**/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}