Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 177 additions & 0 deletions .github/workflows/homebrew-cask-codexel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
name: homebrew-cask-codexel

on:
workflow_dispatch:
inputs:
tag:
description: "Existing Codexel tag (e.g. codexel-v0.1.3)"
required: true
type: string

jobs:
build-macos:
name: Build macOS assets - ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
defaults:
run:
working-directory: codex-rs
strategy:
fail-fast: false
matrix:
include:
- runner: macos-14
target: aarch64-apple-darwin
- runner: macos-13
target: x86_64-apple-darwin
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.tag }}

- uses: dtolnay/rust-toolchain@1.90
with:
targets: ${{ matrix.target }}

- uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
${{ github.workspace }}/codex-rs/target/
key: cargo-${{ matrix.runner }}-${{ matrix.target }}-release-${{ hashFiles('**/Cargo.lock') }}

- name: Cargo build
shell: bash
run: cargo build --target ${{ matrix.target }} --release --bin codexel

- name: Package tarball
shell: bash
run: |
set -euo pipefail
out_dir="${GITHUB_WORKSPACE}/dist"
mkdir -p "$out_dir"
bin_path="target/${{ matrix.target }}/release/codexel"
chmod +x "$bin_path"
tar -C "$(dirname "$bin_path")" -czf "$out_dir/codexel-${{ matrix.target }}.tar.gz" codexel

- uses: actions/upload-artifact@v6
with:
name: codexel-${{ matrix.target }}-tarball
path: dist/codexel-${{ matrix.target }}.tar.gz
if-no-files-found: error

publish-homebrew:
name: Upload assets + update tap cask
needs: build-macos
runs-on: ubuntu-latest
permissions:
contents: write
env:
TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
steps:
- name: Validate tag
shell: bash
run: |
set -euo pipefail
[[ "${{ inputs.tag }}" =~ ^codexel-v[0-9]+\.[0-9]+\.[0-9]+(-((alpha|beta)\.[0-9]+))?$ ]] \
|| { echo "Tag '${{ inputs.tag }}' doesn't match expected format"; exit 1; }

- name: Download tarballs
uses: actions/download-artifact@v7
with:
path: dist

- name: Move tarballs into dist/
shell: bash
run: |
set -euo pipefail
shopt -s nullglob
for tarball in dist/*/codexel-*-apple-darwin.tar.gz; do
mv "$tarball" dist/
done
ls -la dist

- name: Upload macOS assets to GitHub Release
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euo pipefail
gh release upload "${{ inputs.tag }}" dist/codexel-*-apple-darwin.tar.gz \
--repo Ixe1/codexel \
--clobber

- name: Compute sha256
id: shas
shell: bash
run: |
set -euo pipefail
sha_arm=$(sha256sum dist/codexel-aarch64-apple-darwin.tar.gz | cut -d' ' -f1)
sha_intel=$(sha256sum dist/codexel-x86_64-apple-darwin.tar.gz | cut -d' ' -f1)
echo "arm=$sha_arm" >> "$GITHUB_OUTPUT"
echo "intel=$sha_intel" >> "$GITHUB_OUTPUT"

- name: Verify Homebrew tap token configured
shell: bash
run: |
set -euo pipefail
if [[ -z "${TAP_TOKEN}" ]]; then
echo "Missing HOMEBREW_TAP_GITHUB_TOKEN secret; cannot update Ixe1/homebrew-tap." >&2
exit 1
fi

- name: Checkout Homebrew tap
if: ${{ env.TAP_TOKEN != '' }}
uses: actions/checkout@v6
with:
repository: Ixe1/homebrew-tap
token: ${{ env.TAP_TOKEN }}
path: homebrew-tap

- name: Update cask
if: ${{ env.TAP_TOKEN != '' }}
shell: bash
run: |
set -euo pipefail
version="${{ inputs.tag }}"
version="${version#codexel-v}"
sha_arm="${{ steps.shas.outputs.arm }}"
sha_intel="${{ steps.shas.outputs.intel }}"

mkdir -p homebrew-tap/Casks
cat > homebrew-tap/Casks/codexel.rb <<EOF
cask "codexel" do
version "${version}"
sha256 arm: "${sha_arm}",
intel: "${sha_intel}"

url "https://github.com/Ixe1/codexel/releases/download/codexel-v#{version}/codexel-#{arch}.tar.gz",
arch: {
arm: "aarch64-apple-darwin",
intel: "x86_64-apple-darwin",
}
name "Codexel"
desc "Codex CLI community fork"
homepage "https://github.com/Ixe1/codexel"
license "Apache-2.0"

binary "codexel"
end
EOF

- name: Commit and push
if: ${{ env.TAP_TOKEN != '' }}
working-directory: homebrew-tap
shell: bash
run: |
set -euo pipefail
version="${{ inputs.tag }}"
version="${version#codexel-v}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Casks/codexel.rb
git commit -m "codexel ${version}" || exit 0
git push
99 changes: 87 additions & 12 deletions .github/workflows/npm-publish-codexel.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
name: npm-publish-codexel

on:
push:
tags:
- "codexel-v*"
workflow_dispatch:
inputs:
tag:
description: "Existing Codexel tag (e.g. codexel-v0.1.3)"
required: true
type: string
publish_npm:
description: "Publish @ixe1/codexel to npm"
required: true
default: false
type: boolean
update_homebrew:
description: "Update the Homebrew cask in Ixe1/homebrew-tap"
required: true
default: true
type: boolean

concurrency:
group: ${{ github.workflow }}
group: ${{ github.workflow }}-${{ inputs.tag }}
cancel-in-progress: true

jobs:
Expand All @@ -18,6 +31,8 @@ jobs:
should_publish: ${{ steps.validate.outputs.should_publish }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.tag }}

- name: Validate tag matches codex-cli package version
id: validate
Expand All @@ -26,12 +41,11 @@ jobs:
set -euo pipefail
echo "::group::Tag validation"

[[ "${GITHUB_REF_TYPE}" == "tag" ]] \
|| { echo "Not a tag push"; exit 1; }
[[ "${GITHUB_REF_NAME}" =~ ^codexel-v[0-9]+\.[0-9]+\.[0-9]+(-((alpha|beta)\.[0-9]+))?$ ]] \
|| { echo "Tag '${GITHUB_REF_NAME}' doesn't match expected format"; exit 1; }
tag="${{ inputs.tag }}"
[[ "${tag}" =~ ^codexel-v[0-9]+\.[0-9]+\.[0-9]+(-((alpha|beta)\.[0-9]+))?$ ]] \
|| { echo "Tag '${tag}' doesn't match expected format"; exit 1; }

tag_version="${GITHUB_REF_NAME#codexel-v}"
tag_version="${tag#codexel-v}"
package_version=$(python -c 'import json; print(json.load(open("codex-cli/package.json", "r", encoding="utf-8"))["version"])')

if [[ "${package_version}" == *-dev ]]; then
Expand Down Expand Up @@ -74,13 +88,19 @@ jobs:
- runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-musl
install_musl: true
- runner: macos-14
target: aarch64-apple-darwin
- runner: macos-13
target: x86_64-apple-darwin
- runner: windows-latest
target: x86_64-pc-windows-msvc
- runner: windows-11-arm
target: aarch64-pc-windows-msvc

steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.tag }}
- uses: dtolnay/rust-toolchain@1.90
with:
targets: ${{ matrix.target }}
Expand Down Expand Up @@ -136,6 +156,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: ${{ inputs.tag }}

- name: Setup Node.js
uses: actions/setup-node@v6
Expand Down Expand Up @@ -203,6 +225,8 @@ jobs:
targets=(
"aarch64-unknown-linux-musl"
"x86_64-unknown-linux-musl"
"aarch64-apple-darwin"
"x86_64-apple-darwin"
"aarch64-pc-windows-msvc"
"x86_64-pc-windows-msvc"
)
Expand Down Expand Up @@ -268,6 +292,9 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: write
env:
HOMEBREW_TAP_REPO: Ixe1/homebrew-tap
TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
steps:
- name: Download build artifacts
uses: actions/download-artifact@v7
Expand All @@ -291,6 +318,8 @@ jobs:
cp "$codex_dir/codexel.exe" "dist/codexel-${target}.exe"
elif [[ -f "$codex_dir/codexel" ]]; then
cp "$codex_dir/codexel" "dist/codexel-${target}"
chmod +x "$codex_dir/codexel"
tar -C "$codex_dir" -czf "dist/codexel-${target}.tar.gz" codexel
else
echo "No codexel binary found in $codex_dir" >&2
exit 1
Expand All @@ -302,7 +331,8 @@ jobs:
shell: bash
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#codexel-v}"
version="${{ inputs.tag }}"
version="${version#codexel-v}"
prerelease="false"
if [[ "${version}" == *-* ]]; then
prerelease="true"
Expand All @@ -314,18 +344,63 @@ jobs:
uses: softprops/action-gh-release@v2
with:
name: ${{ steps.release_meta.outputs.version }}
tag_name: ${{ github.ref_name }}
tag_name: ${{ inputs.tag }}
files: dist/**
prerelease: ${{ steps.release_meta.outputs.prerelease }}
generate_release_notes: true

- name: Checkout Homebrew tap
if: ${{ inputs.update_homebrew && env.TAP_TOKEN != '' }}
uses: actions/checkout@v6
with:
repository: ${{ env.HOMEBREW_TAP_REPO }}
token: ${{ env.TAP_TOKEN }}
path: homebrew-tap

- name: Update Homebrew cask
if: ${{ inputs.update_homebrew && env.TAP_TOKEN != '' }}
shell: bash
run: |
set -euo pipefail
version="${{ steps.release_meta.outputs.version }}"
sha_arm=$(sha256sum "dist/codexel-aarch64-apple-darwin.tar.gz" | cut -d' ' -f1)
sha_intel=$(sha256sum "dist/codexel-x86_64-apple-darwin.tar.gz" | cut -d' ' -f1)

mkdir -p homebrew-tap/Casks
cat > homebrew-tap/Casks/codexel.rb <<EOF
cask "codexel" do
version "${version}"
sha256 arm: "${sha_arm}",
intel: "${sha_intel}"

url "https://github.com/Ixe1/codexel/releases/download/codexel-v#{version}/codexel-#{arch}.tar.gz",
arch: {
arm: "aarch64-apple-darwin",
intel: "x86_64-apple-darwin",
}
name "Codexel"
desc "Codex CLI community fork"
homepage "https://github.com/Ixe1/codexel"
license "Apache-2.0"

binary "codexel"
end
EOF

cd homebrew-tap
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Casks/codexel.rb
git commit -m "codexel ${version}" || exit 0
git push

publish:
name: Publish npm package
needs:
- tag-check
- package
- smoke-test
if: ${{ needs.tag-check.outputs.should_publish == 'true' }}
if: ${{ inputs.publish_npm && needs.tag-check.outputs.should_publish == 'true' }}
runs-on: ubuntu-latest
permissions:
id-token: write
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
name: Format / etc
runs-on: ubuntu-24.04
needs: changed
if: ${{ (needs.changed.outputs.codex == 'true' || needs.changed.outputs.workflows == 'true' || github.event_name == 'push') && !(github.event_name == 'pull_request' && startsWith(matrix.runner, 'macos')) }}
if: ${{ needs.changed.outputs.codex == 'true' || needs.changed.outputs.workflows == 'true' || github.event_name == 'push' }}
defaults:
run:
working-directory: codex-rs
Expand All @@ -71,7 +71,7 @@ jobs:
name: cargo shear
runs-on: ubuntu-24.04
needs: changed
if: ${{ (needs.changed.outputs.codex == 'true' || needs.changed.outputs.workflows == 'true' || github.event_name == 'push') && !(github.event_name == 'pull_request' && startsWith(matrix.runner, 'macos')) }}
if: ${{ needs.changed.outputs.codex == 'true' || needs.changed.outputs.workflows == 'true' || github.event_name == 'push' }}
defaults:
run:
working-directory: codex-rs
Expand Down
Loading
Loading