Update .github/workflows/release.yml

This commit is contained in:
gigirassy
2025-10-20 04:41:35 +02:00
parent 71a34ae77f
commit f4718fa3c6
+68 -25
View File
@@ -1,4 +1,3 @@
# .github/workflows/release.yml
name: Build & Release Go Binary name: Build & Release Go Binary
on: on:
@@ -11,40 +10,84 @@ permissions:
packages: write packages: write
jobs: jobs:
release: prepare_release:
name: Prepare release (create tag + release)
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.set_tag.outputs.TAG }}
steps:
- name: Checkout (full history required for tagging)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set TAG
id: set_tag
run: |
TAG="v$(date +'%Y%m%d%H%M%S')"
echo "TAG=${TAG}" >> $GITHUB_OUTPUT
- name: Configure git user
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Create and push tag
run: |
git tag ${{ steps.set_tag.outputs.TAG }}
git push origin ${{ steps.set_tag.outputs.TAG }}
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.set_tag.outputs.TAG }}
name: ${{ steps.set_tag.outputs.TAG }}
token: ${{ secrets.GITHUB_TOKEN }}
build_and_upload:
name: Build and upload artifacts
needs: prepare_release
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
goos: [linux, windows, darwin] goos: [linux, windows, darwin]
goarch: ['386', amd64, arm64] goarch: [amd64, arm64]
exclude: exclude:
- goos: darwin - goos: darwin
goarch: '386' goarch: '386'
- goos: windows - goos: windows
goarch: arm64 goarch: arm64
steps: steps:
- uses: actions/checkout@v4 - name: Checkout
- name: Set version tag uses: actions/checkout@v4
id: version
run: | - name: Setup Go
VERSION="v$(date +'%Y%m%d%H%M%S')" uses: actions/setup-go@v4
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build Go Binary
uses: wangyoucao577/go-release-action@v1
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} go-version: '1.24.8'
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }} - name: Build binary
goversion: "https://dl.google.com/go/go1.24.8.linux-amd64.tar.gz"
project_path: "./"
binary_name: "pinata"
extra_files: LICENSE README.md
- name: Create Git Tag
run: | run: |
git tag ${{ env.VERSION }} set -e
git push origin ${{ env.VERSION }} EXT=""
- name: Create GitHub Release if [ "${{ matrix.goos }}" = "windows" ]; then EXT=".exe"; fi
uses: ncipollo/release-action@v1 OUT_DIR=build-artifacts
mkdir -p ${OUT_DIR}
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
go build -o ${OUT_DIR}/pinata-${{ matrix.goos }}-${{ matrix.goarch }}${EXT} ./cmd/pinata
- name: Package artifact (tar/gzip)
if: matrix.goos == 'linux'
run: |
cd build-artifacts
tar -czf ../pinata-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz pinata-${{ matrix.goos }}-${{ matrix.goarch }}
ls -lh ..
- name: Upload artifact to the Release
# softprops/action-gh-release will find the release by tag and upload files
uses: softprops/action-gh-release@v1
with: with:
tag: ${{ env.VERSION }} files: |
token: ${{ secrets.GITHUB_TOKEN }} build-artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}