|
| 1 | +name: Release Binaries |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + binary: |
| 7 | + options: |
| 8 | + - thor |
| 9 | + - disco |
| 10 | + description: 'Select the binary to build and release' |
| 11 | + type: choice |
| 12 | + required: true |
| 13 | + default: thor |
| 14 | + workflow_call: |
| 15 | + inputs: |
| 16 | + binary: |
| 17 | + description: 'Select the binary to build and release' |
| 18 | + type: string |
| 19 | + required: true |
| 20 | + default: thor |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: write |
| 24 | + |
| 25 | +jobs: |
| 26 | + build-binaries: |
| 27 | + runs-on: ${{ matrix.hostos }} |
| 28 | + strategy: |
| 29 | + fail-fast: false |
| 30 | + matrix: |
| 31 | + include: |
| 32 | + - goos: linux |
| 33 | + goarch: amd64 |
| 34 | + hostos: ubuntu-latest |
| 35 | + - goos: linux |
| 36 | + goarch: arm64 |
| 37 | + hostos: ubuntu-24.04-arm |
| 38 | + - goos: darwin |
| 39 | + goarch: arm64 |
| 40 | + hostos: macos-latest |
| 41 | + - goos: windows |
| 42 | + goarch: amd64 |
| 43 | + hostos: windows-latest |
| 44 | + steps: |
| 45 | + - name: Checkout |
| 46 | + uses: actions/checkout@v5 |
| 47 | + with: |
| 48 | + fetch-depth: 0 |
| 49 | + |
| 50 | + - name: Set up Go |
| 51 | + uses: actions/setup-go@v5 |
| 52 | + with: |
| 53 | + go-version: 1.24 |
| 54 | + |
| 55 | + - name: Install GoReleaser |
| 56 | + uses: goreleaser/goreleaser-action@v6 |
| 57 | + with: |
| 58 | + install-only: true |
| 59 | + |
| 60 | +# - name: Import GPG key |
| 61 | +# id: import_gpg |
| 62 | +# uses: crazy-max/ghaction-import-gpg@v6 |
| 63 | +# with: |
| 64 | +# gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} |
| 65 | +# passphrase: ${{ secrets.PASSPHRASE }} |
| 66 | + |
| 67 | + - name: Set Env |
| 68 | + run: | |
| 69 | + echo "BINARY=${{ inputs.binary || 'thor' }}" >> $GITHUB_ENV |
| 70 | + echo "BIN_EXT=${{ matrix.goos == 'windows' && '.exe' || '' }}" >> $GITHUB_ENV |
| 71 | + echo "THOR_VERSION=$(cat ./cmd/thor/VERSION | tr -d '\n')" >> $GITHUB_ENV |
| 72 | + echo "DISCO_VERSION=$(cat ./cmd/disco/VERSION | tr -d '\n')" >> $GITHUB_ENV |
| 73 | + echo "COPYRIGHT_YEAR=$(git --no-pager log -1 --format=%ad --date=format:%Y)" >> $GITHUB_ENV |
| 74 | +
|
| 75 | + - name: Build Binary |
| 76 | + run: goreleaser build --single-target --id ${{ env.BINARY }} --clean |
| 77 | + env: |
| 78 | + DISCO_VERSION: ${{ env.DISCO_VERSION }} |
| 79 | + THOR_VERSION: ${{ env.THOR_VERSION }} |
| 80 | + COPYRIGHT_YEAR: ${{ env.COPYRIGHT_YEAR }} |
| 81 | + #GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} |
| 82 | + |
| 83 | + - name: Debug |
| 84 | + run: | |
| 85 | + ls -lh ./dist |
| 86 | +
|
| 87 | + - name: Upload Artifacts |
| 88 | + uses: actions/upload-artifact@v4 |
| 89 | + with: |
| 90 | + path: ./dist/${{ env.BINARY}}* |
| 91 | + name: 'binaries' |
| 92 | + |
| 93 | + publish-binaries: |
| 94 | + needs: build-binaries |
| 95 | + runs-on: ubuntu-latest |
| 96 | + if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' }} |
| 97 | + steps: |
| 98 | + - name: Download Artifacts |
| 99 | + uses: actions/download-artifact@v5 |
| 100 | + with: |
| 101 | + name: 'binaries' |
| 102 | + path: './dist' |
| 103 | + |
| 104 | +# - name: Import GPG key |
| 105 | +# id: import_gpg |
| 106 | +# uses: crazy-max/ghaction-import-gpg@v6 |
| 107 | +# with: |
| 108 | +# gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} |
| 109 | +# passphrase: ${{ secrets.PASSPHRASE }} |
| 110 | + |
| 111 | + - name: Install GoReleaser |
| 112 | + uses: goreleaser/goreleaser-action@v6 |
| 113 | + with: |
| 114 | + distribution: goreleaser |
| 115 | + version: "~> v2" |
| 116 | + args: release |
| 117 | + env: |
| 118 | + # GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} |
0 commit comments