Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146# Build and Release workflow for Goname: Go
on: push: branches: [ "master" ] tags: - "v*" pull_request: branches: [ "master" ]
permissions: contents: write # needed to create releases
jobs: build: runs-on: ubuntu-latest strategy: fail-fast: false matrix: include: # Linux - goos: linux goarch: amd64 ext: "" - goos: linux goarch: arm64 ext: "" - goos: linux goarch: arm goarm: "7" ext: "" # Windows - goos: windows goarch: amd64 ext: ".exe" - goos: windows goarch: arm64 ext: ".exe" # macOS - goos: darwin goarch: arm64 ext: "" - goos: darwin goarch: amd64 ext: ""
steps: - uses: actions/checkout@v6
- name: Set up Go uses: actions/setup-go@v6 with: go-version: '1.26'
- name: Build ${{ matrix.goos }}/${{ matrix.goarch }}${{ matrix.goarm && format(' (GOARM={0})', matrix.goarm) || '' }} env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} CGO_ENABLED: 0 GOARM: ${{ matrix.goarm || '' }} run: | mkdir -p dist if [ -n "${GOARM}" ]; then SUF="${GOOS}-${GOARCH}-${GOARM}"; else SUF="${GOOS}-${GOARCH}"; fi OUT="dist/compressor-${SUF}${{ matrix.ext }}" echo "Building -> $OUT" go build -trimpath -ldflags "-s -w" -o "$OUT" ./...
- name: Upload artifact ${{ matrix.goos }}/${{ matrix.goarch }}${{ matrix.goarm && format('-{0}', matrix.goarm) || '' }} uses: actions/upload-artifact@v7 with: name: compressor-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm && format('-{0}', matrix.goarm) || '' }} path: dist/compressor-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm && format('-{0}', matrix.goarm) || '' }}${{ matrix.ext }} if-no-files-found: error
# Pre-Releases release_sha: name: Create per-commit prerelease needs: build runs-on: ubuntu-latest # Only create releases for direct pushes to master (not PRs) if: github.event_name == 'push' && github.ref == 'refs/heads/master' steps: - name: Download all build artifacts uses: actions/download-artifact@v8 with: pattern: compressor-* merge-multiple: true path: dist
- name: Show downloaded files run: | echo "Downloaded artifacts:" ls -R dist
- name: Create prerelease for commit uses: softprops/action-gh-release@v2 with: tag_name: commit-${{ github.sha }} name: Commit ${{ github.sha }} prerelease: true body: | Automated prerelease for commit ${{ github.sha }} on ${{ github.ref_name }}. Includes cross-compiled binaries: - linux/amd64 - linux/arm64 - linux/arm (GOARM=7) - windows/amd64 - windows/arm64 - darwin/amd64 - darwin/arm64 files: | dist/* env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Version Release release_tag: name: Create tagged release needs: build runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') steps: - name: Download all build artifacts uses: actions/download-artifact@v8 with: pattern: compressor-* merge-multiple: true path: dist
- name: Show downloaded files run: | echo "Downloaded artifacts:" ls -R dist
- name: Create GitHub Release with binaries uses: softprops/action-gh-release@v2 with: tag_name: ${{ github.ref_name }} name: ${{ github.ref_name }} prerelease: false files: | dist/* env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}