name: Build and Release on: push: tags: - '*' jobs: build: name: Build runs-on: self-hosted steps: - name: Set up Go uses: actions/setup-go@v4 with: go-version: '1.21' - name: Check out code uses: actions/checkout@v4 - name: Cross-compile with xgo uses: crazy-max/ghaction-xgo@v3 with: xgo_version: latest go_version: 1.21 pkg: ./cmd/zurg dest: artifacts prefix: zurg targets: windows/amd64,linux/amd64,linux/arm64,darwin/arm64 v: true x: false race: false ldflags: -s -w buildmode: default trimpath: true - name: Compress artifacts run: | mkdir -p compressed_artifacts for platform in windows-amd64.exe linux-amd64 linux-arm64 darwin-arm64; do zip -r "compressed_artifacts/zurg-$platform-${{ github.ref }}.zip" "artifacts/zurg-$platform" done - name: Upload artifacts to workflow uses: actions/upload-artifact@v3 with: name: compiled-binaries path: compressed_artifacts/*.zip release: needs: build runs-on: ubuntu-latest steps: - name: Download artifacts uses: actions/download-artifact@v3 with: name: compiled-binaries - name: Create Release id: create_release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.ref }} release_name: Release ${{ github.ref }} draft: false prerelease: false - name: Upload binaries to release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | for platform in windows/amd64 linux/amd64 linux/arm64 darwin/arm64; do asset_path="./compressed_artifacts/zurg-$platform-${{ github.ref }}.zip" if [[ -f "$asset_path" ]]; then echo "Uploading $asset_path" gh release upload ${{ github.ref }} "$asset_path" --c ${{ secrets.GITHUB_TOKEN }} else echo "File not found: $asset_path" fi done