mirror of
https://codeberg.org/gigirassy/pinata
synced 2026-08-30 23:37:40 +00:00
85 lines
2.3 KiB
YAML
85 lines
2.3 KiB
YAML
name: Build & Release Go Binary
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
jobs:
|
|
prepare_release:
|
|
name: 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: Create TAG
|
|
id: set_tag
|
|
run: |
|
|
TAG="v$(date +'%Y%m%d%H%M%S')"
|
|
echo "TAG=${TAG}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Push tag
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
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 & upload artifacts
|
|
needs: prepare_release
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
goos: [linux, windows, darwin]
|
|
goarch: [amd64, arm64]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version: '1.24.8'
|
|
|
|
- name: Build
|
|
run: |
|
|
EXT=""
|
|
if [ "${{ matrix.goos }}" = "windows" ]; then EXT=".exe"; fi
|
|
OUT=build-artifacts
|
|
mkdir -p $OUT
|
|
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
|
|
go build -o ${OUT}/pinata-${{ matrix.goos }}-${{ matrix.goarch }}${EXT} ./
|
|
|
|
- name: Package (example for linux)
|
|
if: matrix.goos == 'linux'
|
|
run: |
|
|
tar -czf pinata-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz build-artifacts/pinata-${{ matrix.goos }}-${{ matrix.goarch }}
|
|
|
|
- name: Upload artifacts to the Release
|
|
uses: ncipollo/release-action@v1
|
|
with:
|
|
tag: ${{ needs.prepare_release.outputs.tag }}
|
|
files: |
|
|
build-artifacts/*
|
|
*.tar.gz
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|