Skip to content

Instantly share code, notes, and snippets.

@magickatt
Created January 18, 2024 20:43
Show Gist options
  • Select an option

  • Save magickatt/5d15e4cd8e675aa513bb5b78e2ded2e7 to your computer and use it in GitHub Desktop.

Select an option

Save magickatt/5d15e4cd8e675aa513bb5b78e2ded2e7 to your computer and use it in GitHub Desktop.

Revisions

  1. magickatt created this gist Jan 18, 2024.
    60 changes: 60 additions & 0 deletions latest_release.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,60 @@
    name: Latest Release

    # Customise for the tag format you are using
    on:
    push:
    tags:
    - v*

    # Required for the release action to upload artifacts
    permissions:
    contents: write

    jobs:

    build-go-artifacts:
    name: Build
    runs-on: ubuntu-latest

    # Customise for as many architectures as necessary
    strategy:
    matrix:
    goosarch:
    - 'darwin/amd64'
    - 'darwin/arm64'
    - 'linux/amd64'
    - 'linux/arm64'
    steps:

    - name: Checkout code
    uses: actions/checkout@v3
    with:
    fetch-depth: 0

    - name: Setup Go
    uses: actions/setup-go@v4
    with:
    go-version: '1.20.12'

    - name: Determine OS and architecture information
    run: |
    GOOSARCH=${{matrix.goosarch}}
    GOOS=${GOOSARCH%/*}
    GOARCH=${GOOSARCH#*/}
    BINARY_NAME=sactl-$GOOS-$GOARCH
    echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV
    echo "GOOS=$GOOS" >> $GITHUB_ENV
    echo "GOARCH=$GOARCH" >> $GITHUB_ENV
    mkdir artifacts
    - name: Build artifacts
    run: |
    go build -o "artifacts/$BINARY_NAME" -v
    - name: Upload artifacts to release
    uses: softprops/action-gh-release@v1
    with:
    files: artifacts/*
    append_body: true
    env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}