|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: ["v*"] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + runs-on: windows-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + fetch-depth: 0 |
| 18 | + |
| 19 | + - uses: actions/setup-go@v5 |
| 20 | + with: |
| 21 | + go-version-file: go.mod |
| 22 | + |
| 23 | + - name: Get version |
| 24 | + id: version |
| 25 | + run: echo "tag=${{ github.ref_name }}" >> $env:GITHUB_OUTPUT |
| 26 | + |
| 27 | + - name: Build Windows binaries |
| 28 | + shell: bash |
| 29 | + run: | |
| 30 | + VERSION="${{ steps.version.outputs.tag }}" |
| 31 | + for arch in amd64 arm64; do |
| 32 | + suffix="" |
| 33 | + if [ "$arch" = "arm64" ]; then suffix="-arm64"; fi |
| 34 | + GOOS=windows GOARCH=$arch go build -trimpath \ |
| 35 | + -ldflags "-s -w -X main.version=$VERSION" \ |
| 36 | + -o "codex-browser-bridge-windows${suffix}.exe" ./cmd/bridge |
| 37 | + done |
| 38 | +
|
| 39 | + - name: Build Linux binaries |
| 40 | + shell: bash |
| 41 | + run: | |
| 42 | + VERSION="${{ steps.version.outputs.tag }}" |
| 43 | + for arch in amd64 arm64; do |
| 44 | + suffix="" |
| 45 | + if [ "$arch" = "arm64" ]; then suffix="-arm64"; fi |
| 46 | + GOOS=linux GOARCH=$arch go build -trimpath \ |
| 47 | + -ldflags "-s -w -X main.version=$VERSION" \ |
| 48 | + -o "codex-browser-bridge-linux${suffix}" ./cmd/bridge |
| 49 | + tar czf "codex-browser-bridge-linux${suffix}.tar.gz" "codex-browser-bridge-linux${suffix}" |
| 50 | + rm "codex-browser-bridge-linux${suffix}" |
| 51 | + done |
| 52 | +
|
| 53 | + - name: Build macOS binaries |
| 54 | + shell: bash |
| 55 | + run: | |
| 56 | + VERSION="${{ steps.version.outputs.tag }}" |
| 57 | + for arch in amd64 arm64; do |
| 58 | + suffix="" |
| 59 | + if [ "$arch" = "arm64" ]; then suffix="-arm64"; fi |
| 60 | + GOOS=darwin GOARCH=$arch go build -trimpath \ |
| 61 | + -ldflags "-s -w -X main.version=$VERSION" \ |
| 62 | + -o "codex-browser-bridge-darwin${suffix}" ./cmd/bridge |
| 63 | + tar czf "codex-browser-bridge-darwin${suffix}.tar.gz" "codex-browser-bridge-darwin${suffix}" |
| 64 | + rm "codex-browser-bridge-darwin${suffix}" |
| 65 | + done |
| 66 | +
|
| 67 | + - name: Generate checksums |
| 68 | + shell: bash |
| 69 | + run: sha256sum codex-browser-bridge-*.{exe,tar.gz} > checksums.txt |
| 70 | + |
| 71 | + - name: Generate release notes |
| 72 | + id: notes |
| 73 | + shell: bash |
| 74 | + run: | |
| 75 | + if [ -f CHANGELOG.md ]; then |
| 76 | + notes=$(awk '/^## \[/{if(found) exit; found=1; next} found{print}' CHANGELOG.md) |
| 77 | + fi |
| 78 | + if [ -z "$notes" ]; then |
| 79 | + notes=$(git log --oneline --no-merges $(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || git rev-list --max-parents=0 HEAD)..HEAD) |
| 80 | + fi |
| 81 | + echo "notes<<EOF" >> $GITHUB_OUTPUT |
| 82 | + echo "$notes" >> $GITHUB_OUTPUT |
| 83 | + echo "EOF" >> $GITHUB_OUTPUT |
| 84 | +
|
| 85 | + - name: Create GitHub Release |
| 86 | + env: |
| 87 | + GH_TOKEN: ${{ github.token }} |
| 88 | + run: | |
| 89 | + gh release create "${{ steps.version.outputs.tag }}" ` |
| 90 | + --title "${{ steps.version.outputs.tag }}" ` |
| 91 | + --notes "${{ steps.notes.outputs.notes }}" ` |
| 92 | + codex-browser-bridge-*.exe ` |
| 93 | + codex-browser-bridge-*.tar.gz ` |
| 94 | + checksums.txt |
0 commit comments