name: Check for Updates on: schedule: - cron: '0 * * * *' workflow_dispatch: inputs: version: description: 'Specific version to update to (optional)' required: false permissions: contents: write pull-requests: write jobs: check-update: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: token: ${{ secrets.GITHUB_TOKEN }} - uses: cachix/install-nix-action@v27 with: nix_path: nixpkgs=channel:nixos-unstable extra_nix_config: | experimental-features = nix-command flakes - name: Check for new version id: check env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | CURRENT_VERSION=$(grep 'version = ' package.nix | cut -d'"' -f2 | head -1) echo "Current version: $CURRENT_VERSION" if [ -n "${{ github.event.inputs.version }}" ]; then LATEST_VERSION="${{ github.event.inputs.version }}" else # Get latest version from GitHub releases (strip rust-v prefix) LATEST_VERSION=$(gh release view --repo openai/codex --json tagName -q '.tagName' | sed 's/^rust-v//' || echo "") fi if [ -z "$LATEST_VERSION" ]; then echo "Could not fetch latest version" exit 0 fi echo "Latest version: $LATEST_VERSION" if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then echo "new_version=$LATEST_VERSION" >> $GITHUB_OUTPUT echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT echo "update_needed=true" >> $GITHUB_OUTPUT else echo "update_needed=false" >> $GITHUB_OUTPUT fi - name: Update version if: steps.check.outputs.update_needed == 'true' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | NEW_VERSION="${{ steps.check.outputs.new_version }}" ./scripts/update.sh --version "$NEW_VERSION" - name: Create Pull Request if: steps.check.outputs.update_needed == 'true' id: create-pr uses: peter-evans/create-pull-request@v6 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "chore: update codex to version ${{ steps.check.outputs.new_version }}" title: "chore: update codex to version ${{ steps.check.outputs.new_version }}" body: | ## Update Codex This PR updates Codex from version ${{ steps.check.outputs.current_version }} to ${{ steps.check.outputs.new_version }}. ### Changes - Updated `version` in `package.nix` - Updated native binary hashes for all platforms - Updated npm tarball hash ### Checklist - [ ] Build passes - [ ] Basic functionality tested --- *This PR was automatically generated by the update workflow.* branch: update-codex-${{ steps.check.outputs.new_version }} delete-branch: true labels: | dependencies automated - name: Enable Auto-Merge if: steps.check.outputs.update_needed == 'true' && steps.create-pr.outputs.pull-request-number env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh pr merge ${{ steps.create-pr.outputs.pull-request-number }} --auto --squash --delete-branch - name: Summary if: always() run: | echo "## Update Summary" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY if [ "${{ steps.check.outputs.update_needed }}" == "true" ]; then echo "- **Current Version:** ${{ steps.check.outputs.current_version }}" >> $GITHUB_STEP_SUMMARY echo "- **Latest Version:** ${{ steps.check.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "✅ Pull request created for version update with auto-merge enabled!" >> $GITHUB_STEP_SUMMARY else CURRENT_VERSION=$(grep 'version = ' package.nix | cut -d'"' -f2 | head -1) echo "- **Current Version:** $CURRENT_VERSION" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "✅ Already up to date!" >> $GITHUB_STEP_SUMMARY fi