|
| 1 | +name: Release CLI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + release_build: |
| 14 | + name: Build Linux amd64 |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
| 22 | + fetch-tags: true |
| 23 | + |
| 24 | + - name: Wait for CI checks |
| 25 | + uses: actions/github-script@v7 |
| 26 | + with: |
| 27 | + script: | |
| 28 | + // Wait for CI to pass before releasing |
| 29 | + const checkRuns = await github.rest.checks.listForRef({ |
| 30 | + owner: context.repo.owner, |
| 31 | + repo: context.repo.repo, |
| 32 | + ref: context.sha, |
| 33 | + }); |
| 34 | +
|
| 35 | + const requiredChecks = ['go-tests', 'lint', 'web-tests']; |
| 36 | + const failedChecks = checkRuns.data.check_runs.filter(check => |
| 37 | + requiredChecks.includes(check.name) && check.conclusion !== 'success' |
| 38 | + ); |
| 39 | +
|
| 40 | + if (failedChecks.length > 0) { |
| 41 | + core.setFailed(`Required checks failed: ${failedChecks.map(c => c.name).join(', ')}`); |
| 42 | + } |
| 43 | +
|
| 44 | + - name: Setup Go |
| 45 | + uses: actions/setup-go@v5 |
| 46 | + with: |
| 47 | + go-version: "1.25.x" |
| 48 | + |
| 49 | + - name: Get version info |
| 50 | + id: version |
| 51 | + run: | |
| 52 | + if [ "${{ github.event_name }}" = "push" ]; then |
| 53 | + TAG="${GITHUB_REF#refs/tags/}" |
| 54 | + VERSION="${TAG#v}" |
| 55 | + else |
| 56 | + TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") |
| 57 | + VERSION="${TAG#v}" |
| 58 | + fi |
| 59 | + BUILD_TIME=$(date -u '+%Y-%m-%d_%H:%M:%S') |
| 60 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 61 | + echo "build_time=$BUILD_TIME" >> $GITHUB_OUTPUT |
| 62 | +
|
| 63 | + - name: Build CLI binary (nofido - no libfido2 dependency) |
| 64 | + env: |
| 65 | + CGO_ENABLED: 0 |
| 66 | + GOOS: linux |
| 67 | + GOARCH: amd64 |
| 68 | + run: | |
| 69 | + go build \ |
| 70 | + -tags nofido \ |
| 71 | + -buildvcs=false \ |
| 72 | + -ldflags "-s -w -X main.Version=${{ steps.version.outputs.version }} -X main.BuildTime=${{ steps.version.outputs.build_time }}" \ |
| 73 | + -o rack-gateway-linux-amd64 \ |
| 74 | + ./cmd/rack-gateway/ |
| 75 | +
|
| 76 | + - name: Verify binary |
| 77 | + run: | |
| 78 | + chmod +x rack-gateway-linux-amd64 |
| 79 | + ./rack-gateway-linux-amd64 version |
| 80 | +
|
| 81 | + - name: Create archive |
| 82 | + run: | |
| 83 | + tar czf rack-gateway-linux-amd64.tar.gz rack-gateway-linux-amd64 |
| 84 | + echo "ASSET_PATH=rack-gateway-linux-amd64.tar.gz" >> $GITHUB_ENV |
| 85 | +
|
| 86 | + - name: Upload artifact |
| 87 | + uses: actions/upload-artifact@v4 |
| 88 | + with: |
| 89 | + name: rack-gateway-linux-amd64 |
| 90 | + path: ${{ env.ASSET_PATH }} |
| 91 | + |
| 92 | + release_create: |
| 93 | + name: Create Release |
| 94 | + needs: release_build |
| 95 | + runs-on: ubuntu-latest |
| 96 | + |
| 97 | + steps: |
| 98 | + - name: Checkout repository |
| 99 | + uses: actions/checkout@v4 |
| 100 | + with: |
| 101 | + fetch-depth: 0 |
| 102 | + fetch-tags: true |
| 103 | + |
| 104 | + - name: Download artifacts |
| 105 | + uses: actions/download-artifact@v4 |
| 106 | + with: |
| 107 | + path: artifacts |
| 108 | + |
| 109 | + - name: Get version |
| 110 | + id: version |
| 111 | + run: | |
| 112 | + if [ "${{ github.event_name }}" = "push" ]; then |
| 113 | + TAG="${GITHUB_REF#refs/tags/}" |
| 114 | + VERSION="${TAG#v}" |
| 115 | + else |
| 116 | + # For workflow_dispatch, use latest tag or generate from commit |
| 117 | + TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") |
| 118 | + VERSION="${TAG#v}" |
| 119 | + fi |
| 120 | +
|
| 121 | + echo "tag=$TAG" >> $GITHUB_OUTPUT |
| 122 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 123 | +
|
| 124 | + - name: Generate checksums |
| 125 | + run: | |
| 126 | + cd artifacts |
| 127 | + for dir in */; do |
| 128 | + cd "$dir" |
| 129 | + for file in *.tar.gz; do |
| 130 | + if [ -f "$file" ]; then |
| 131 | + sha256sum "$file" > "${file}.sha256" |
| 132 | + echo "Generated checksum for $file:" |
| 133 | + cat "${file}.sha256" |
| 134 | + fi |
| 135 | + done |
| 136 | + cd .. |
| 137 | + done |
| 138 | + cd .. |
| 139 | +
|
| 140 | + - name: Generate changelog |
| 141 | + run: | |
| 142 | + TAG="${{ steps.version.outputs.tag }}" |
| 143 | + cat > changelog.md <<EOF |
| 144 | + ## Installation |
| 145 | +
|
| 146 | + This release contains a statically-compiled Linux amd64 binary built without libfido2 support (for CI/CD use). |
| 147 | +
|
| 148 | + ### Linux (x86_64) - CircleCI Machine Runners |
| 149 | + \`\`\`bash |
| 150 | + curl -L https://github.com/${{ github.repository }}/releases/download/${TAG}/rack-gateway-linux-amd64.tar.gz | tar xz |
| 151 | + sudo mv rack-gateway-linux-amd64 /usr/local/bin/rack-gateway |
| 152 | + sudo chmod +x /usr/local/bin/rack-gateway |
| 153 | + rack-gateway version |
| 154 | + \`\`\` |
| 155 | +
|
| 156 | + ### Verify Checksum |
| 157 | + \`\`\`bash |
| 158 | + curl -L https://github.com/${{ github.repository }}/releases/download/${TAG}/rack-gateway-linux-amd64.tar.gz.sha256 -o rack-gateway-linux-amd64.tar.gz.sha256 |
| 159 | + sha256sum -c rack-gateway-linux-amd64.tar.gz.sha256 |
| 160 | + \`\`\` |
| 161 | +
|
| 162 | + **Note:** This binary is built with \`-tags nofido\` (no libfido2 dependency) for use in CI environments. |
| 163 | + For local development with MFA support, build from source with libfido2 installed. |
| 164 | + EOF |
| 165 | +
|
| 166 | + - name: Create Release |
| 167 | + uses: softprops/action-gh-release@v2 |
| 168 | + with: |
| 169 | + tag_name: ${{ steps.version.outputs.tag }} |
| 170 | + name: rack-gateway v${{ steps.version.outputs.version }} |
| 171 | + body_path: changelog.md |
| 172 | + draft: false |
| 173 | + prerelease: ${{ contains(steps.version.outputs.tag, '-') }} |
| 174 | + files: | |
| 175 | + artifacts/**/*.tar.gz |
| 176 | + artifacts/**/*.sha256 |
| 177 | + env: |
| 178 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments