|
1 | 1 | name: ci |
2 | 2 |
|
3 | 3 | on: |
4 | | - pull_request: {} |
5 | | - push: { branches: [main] } |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + workflow_dispatch: {} |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: ci-main-release-${{ github.ref }} |
| 14 | + cancel-in-progress: true |
6 | 15 |
|
7 | 16 | jobs: |
8 | | - build-test: |
| 17 | + metadata: |
| 18 | + name: Resolve Release Metadata |
9 | 19 | runs-on: ubuntu-latest |
10 | | - timeout-minutes: 10 |
11 | | - env: |
12 | | - NODE_OPTIONS: --max-old-space-size=4096 |
| 20 | + outputs: |
| 21 | + base_version: ${{ steps.meta.outputs.base_version }} |
| 22 | + release_tag: ${{ steps.meta.outputs.release_tag }} |
13 | 23 | steps: |
14 | | - - name: Checkout repository |
| 24 | + - name: Checkout |
15 | 25 | uses: actions/checkout@v6 |
16 | 26 |
|
17 | | - - name: Setup pnpm |
18 | | - uses: pnpm/action-setup@v4 |
19 | | - with: |
20 | | - run_install: false |
| 27 | + - name: Resolve version/tag |
| 28 | + id: meta |
| 29 | + shell: bash |
| 30 | + run: | |
| 31 | + set -euo pipefail |
| 32 | + base_version="$(grep -m1 '^version' codex-rs/Cargo.toml | sed -E 's/version *= *\"([^\"]+)\".*/\1/')" |
| 33 | + release_tag="v${base_version}" |
21 | 34 |
|
22 | | - - name: Setup Node.js |
23 | | - uses: actions/setup-node@v6 |
24 | | - with: |
25 | | - node-version: 22 |
| 35 | + echo "base_version=${base_version}" >> "$GITHUB_OUTPUT" |
| 36 | + echo "release_tag=${release_tag}" >> "$GITHUB_OUTPUT" |
26 | 37 |
|
27 | | - - name: Install dependencies |
28 | | - run: pnpm install --frozen-lockfile |
| 38 | + build-binaries: |
| 39 | + name: Build ${{ matrix.target }} |
| 40 | + needs: metadata |
| 41 | + runs-on: ${{ matrix.os }} |
| 42 | + strategy: |
| 43 | + fail-fast: false |
| 44 | + matrix: |
| 45 | + include: |
| 46 | + - os: ubuntu-latest |
| 47 | + target: x86_64-unknown-linux-gnu |
| 48 | + archive_name: codex-x86_64-unknown-linux-gnu.tar.gz |
| 49 | + binary_name: codex |
| 50 | + - os: macos-latest |
| 51 | + target: aarch64-apple-darwin |
| 52 | + archive_name: codex-aarch64-apple-darwin.tar.gz |
| 53 | + binary_name: codex |
| 54 | + - os: windows-latest |
| 55 | + target: x86_64-pc-windows-msvc |
| 56 | + archive_name: codex-x86_64-pc-windows-msvc.zip |
| 57 | + binary_name: codex.exe |
| 58 | + defaults: |
| 59 | + run: |
| 60 | + working-directory: codex-rs |
| 61 | + steps: |
| 62 | + - name: Checkout |
| 63 | + uses: actions/checkout@v6 |
| 64 | + |
| 65 | + - name: Install Linux build dependencies |
| 66 | + if: ${{ runner.os == 'Linux' }} |
| 67 | + shell: bash |
| 68 | + run: | |
| 69 | + set -euo pipefail |
| 70 | + sudo apt-get update |
| 71 | + sudo apt-get install -y --no-install-recommends pkg-config libcap-dev |
29 | 72 |
|
30 | | - # stage_npm_packages.py requires DotSlash when staging releases. |
31 | | - - uses: facebook/install-dotslash@v2 |
| 73 | + - name: Install Rust toolchain |
| 74 | + uses: dtolnay/rust-toolchain@stable |
| 75 | + with: |
| 76 | + targets: ${{ matrix.target }} |
32 | 77 |
|
33 | | - - name: Stage npm package |
34 | | - id: stage_npm_package |
35 | | - env: |
36 | | - GH_TOKEN: ${{ github.token }} |
| 78 | + - name: Build codex |
| 79 | + shell: bash |
37 | 80 | run: | |
38 | 81 | set -euo pipefail |
39 | | - # Use a rust-release version that includes all native binaries. |
40 | | - CODEX_VERSION=0.74.0 |
41 | | - OUTPUT_DIR="${RUNNER_TEMP}" |
42 | | - python3 ./scripts/stage_npm_packages.py \ |
43 | | - --release-version "$CODEX_VERSION" \ |
44 | | - --package codex \ |
45 | | - --output-dir "$OUTPUT_DIR" |
46 | | - PACK_OUTPUT="${OUTPUT_DIR}/codex-npm-${CODEX_VERSION}.tgz" |
47 | | - echo "pack_output=$PACK_OUTPUT" >> "$GITHUB_OUTPUT" |
48 | | -
|
49 | | - - name: Upload staged npm package artifact |
| 82 | + cargo build --release --target "${{ matrix.target }}" --bin codex |
| 83 | +
|
| 84 | + - name: Package artifact (Unix) |
| 85 | + if: ${{ runner.os != 'Windows' }} |
| 86 | + shell: bash |
| 87 | + run: | |
| 88 | + set -euo pipefail |
| 89 | + mkdir -p dist |
| 90 | + cp "target/${{ matrix.target }}/release/${{ matrix.binary_name }}" . |
| 91 | + tar -czf "dist/${{ matrix.archive_name }}" "${{ matrix.binary_name }}" |
| 92 | +
|
| 93 | + - name: Package artifact (Windows) |
| 94 | + if: ${{ runner.os == 'Windows' }} |
| 95 | + shell: pwsh |
| 96 | + run: | |
| 97 | + New-Item -ItemType Directory -Path dist -Force | Out-Null |
| 98 | + Copy-Item "target/${{ matrix.target }}/release/${{ matrix.binary_name }}" "${{ matrix.binary_name }}" -Force |
| 99 | + Compress-Archive -Path "${{ matrix.binary_name }}" -DestinationPath "dist/${{ matrix.archive_name }}" -Force |
| 100 | +
|
| 101 | + - name: Upload artifact |
50 | 102 | uses: actions/upload-artifact@v6 |
51 | 103 | with: |
52 | | - name: codex-npm-staging |
53 | | - path: ${{ steps.stage_npm_package.outputs.pack_output }} |
| 104 | + name: release-${{ matrix.target }} |
| 105 | + path: codex-rs/dist/${{ matrix.archive_name }} |
| 106 | + |
| 107 | + github-release: |
| 108 | + name: Publish GitHub Release |
| 109 | + needs: [metadata, build-binaries] |
| 110 | + runs-on: ubuntu-latest |
| 111 | + steps: |
| 112 | + - name: Download artifacts |
| 113 | + uses: actions/download-artifact@v6 |
| 114 | + with: |
| 115 | + pattern: release-* |
| 116 | + merge-multiple: true |
| 117 | + path: dist |
54 | 118 |
|
55 | | - - name: Ensure root README.md contains only ASCII and certain Unicode code points |
56 | | - run: ./scripts/asciicheck.py README.md |
57 | | - - name: Check root README ToC |
58 | | - run: python3 scripts/readme_toc.py README.md |
| 119 | + - name: Create release notes |
| 120 | + shell: bash |
| 121 | + run: | |
| 122 | + set -euo pipefail |
| 123 | + cat > release-notes.md <<'EOF' |
| 124 | + Automated main-branch release for Codex CLI. |
59 | 125 |
|
60 | | - - name: Ensure codex-cli/README.md contains only ASCII and certain Unicode code points |
61 | | - run: ./scripts/asciicheck.py codex-cli/README.md |
62 | | - - name: Check codex-cli/README ToC |
63 | | - run: python3 scripts/readme_toc.py codex-cli/README.md |
| 126 | + Includes binaries for: |
| 127 | + - macOS (Apple Silicon) |
| 128 | + - Linux (x86_64) |
| 129 | + - Windows (x86_64) |
| 130 | + EOF |
64 | 131 |
|
65 | | - - name: Prettier (run `pnpm run format:fix` to fix) |
66 | | - run: pnpm run format |
| 132 | + - name: Create GitHub Release |
| 133 | + uses: softprops/action-gh-release@v2 |
| 134 | + with: |
| 135 | + tag_name: ${{ needs.metadata.outputs.release_tag }} |
| 136 | + name: v${{ needs.metadata.outputs.base_version }} |
| 137 | + body_path: release-notes.md |
| 138 | + prerelease: ${{ contains(needs.metadata.outputs.base_version, '-') }} |
| 139 | + files: dist/* |
0 commit comments