Release #3
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 | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| test_build: | |
| description: 'Test build only (no release artifacts)' | |
| required: false | |
| default: 'true' | |
| type: boolean | |
| jobs: | |
| build: | |
| name: Build and Release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| strategy: | |
| matrix: | |
| include: | |
| - goos: linux | |
| goarch: amd64 | |
| archive: tar.gz | |
| - goos: linux | |
| goarch: arm64 | |
| archive: tar.gz | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.21' | |
| - name: Install cross-compilation tools | |
| run: | | |
| sudo apt-get update | |
| if [ "${{ matrix.goarch }}" = "arm64" ]; then | |
| sudo apt-get install -y gcc-aarch64-linux-gnu | |
| fi | |
| - name: Build binary | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| CGO_ENABLED: 1 | |
| run: | | |
| binary_name="simplemem" | |
| if [ "${{ matrix.goarch }}" = "arm64" ]; then | |
| export CC=aarch64-linux-gnu-gcc | |
| fi | |
| go build -ldflags="-s -w" -o "${binary_name}" ./cmd/simplemem | |
| - name: Create archive | |
| run: | | |
| binary_name="simplemem" | |
| archive_name="simplemem-${{ github.event.release.tag_name }}-${{ matrix.goos }}-${{ matrix.goarch }}" | |
| tar -czf "${archive_name}.tar.gz" "${binary_name}" README.md LICENSE config.toml.example | |
| echo "ASSET=${archive_name}.tar.gz" >> $GITHUB_ENV | |
| - name: Upload release asset | |
| if: github.event_name == 'release' | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ github.event.release.upload_url }} | |
| asset_path: ./${{ env.ASSET }} | |
| asset_name: ${{ env.ASSET }} | |
| asset_content_type: application/octet-stream |