Release Go Binaries #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release Go Binaries | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version of the release (e.g. v0.3.6)' | |
| required: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| os: [linux, darwin, windows] | |
| arch: [amd64, arm64] | |
| steps: | |
| - name: Checkout source | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.23" | |
| - name: Set version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
| - name: Build binary | |
| run: | | |
| mkdir -p dist | |
| export GOOS=${{ matrix.os }} | |
| export GOARCH=${{ matrix.arch }} | |
| EXT="" | |
| if [ "$GOOS" = "windows" ]; then EXT=".exe"; fi | |
| BINARY_NAME=singul-${GOOS}-${GOARCH} | |
| OUTPUT=dist/$BINARY_NAME$EXT | |
| echo "Building $OUTPUT" | |
| GOOS=$GOOS GOARCH=$GOARCH go build -o $OUTPUT | |
| - name: Package | |
| run: | | |
| cd dist | |
| FILENAME=singul-${{ matrix.os }}-${{ matrix.arch }} | |
| if [ "${{ matrix.os }}" = "windows" ]; then | |
| zip $FILENAME.zip $FILENAME.exe | |
| else | |
| tar -czf $FILENAME.tar.gz $FILENAME | |
| fi | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binaries-${{ matrix.os }}-${{ matrix.arch }} | |
| path: dist/* | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| - name: Flatten artifacts | |
| run: | | |
| find dist -mindepth 2 -type f -exec mv -t dist {} + || true | |
| - name: Upload binaries to GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.event.inputs.version }} | |
| files: dist/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |