← Files PineconeARCHIVED FILE

.github/workflows/release.yml

3.29 KB · Oct 2, 2026 · 00:35 UTC

↓ Download file

name: Release

on:
  pull_request:
    types: [closed]
    branches: [main]

jobs:
  release:
    if: github.event.pull_request.merged == true
    runs-on: ubuntu-latest

    permissions:
      contents: write
      pull-requests: read

    steps:
      - name: Checkout main
        uses: actions/checkout@v7
        with:
          ref: main
          fetch-depth: 0

      - name: Determine bump type
        id: bump
        run: |
          LABELS='${{ toJSON(github.event.pull_request.labels.*.name) }}'
          if echo "$LABELS" | grep -q 'bump:major'; then
            echo "type=major" >> $GITHUB_OUTPUT
          elif echo "$LABELS" | grep -q 'bump:minor'; then
            echo "type=minor" >> $GITHUB_OUTPUT
          else
            echo "type=patch" >> $GITHUB_OUTPUT
          fi

      - name: Bump version
        id: version
        run: |
          CURRENT=$(jq -r '.version' .codex-plugin/plugin.json)
          MAJOR=$(echo $CURRENT | cut -d. -f1)
          MINOR=$(echo $CURRENT | cut -d. -f2)
          PATCH=$(echo $CURRENT | cut -d. -f3)

          BUMP_TYPE="${{ steps.bump.outputs.type }}"
          if [ "$BUMP_TYPE" = "major" ]; then
            NEW_VERSION="$((MAJOR+1)).0.0"
          elif [ "$BUMP_TYPE" = "minor" ]; then
            NEW_VERSION="${MAJOR}.$((MINOR+1)).0"
          else
            NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH+1))"
          fi

          echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
          jq --arg v "$NEW_VERSION" '.version = $v' .codex-plugin/plugin.json > tmp.json && mv tmp.json .codex-plugin/plugin.json

      - name: Update changelog
        env:
          NEW_VERSION: ${{ steps.version.outputs.new_version }}
          PR_NUMBER: ${{ github.event.pull_request.number }}
          GH_TOKEN: ${{ github.token }}
        run: |
          DATE=$(date +%Y-%m-%d)
          HEADER="## [$NEW_VERSION] - $DATE"

          BULLETS=$(gh pr view "$PR_NUMBER" --json commits --jq '.commits[].messageHeadline' | grep -v '^chore:' | grep -v '^\[create-pull-request\]' | sed 's/^/- /')

          if [ -z "$BULLETS" ]; then
            BULLETS="- ${{ github.event.pull_request.title }}"
          fi

          ENTRY=$(printf '%s\n%s\n' "$HEADER" "$BULLETS")

          if grep -q '^# Changelog' CHANGELOG.md; then
            awk -v entry="$ENTRY" '/^# Changelog/{print; print ""; print entry; next}1' CHANGELOG.md > tmp_changelog.md && mv tmp_changelog.md CHANGELOG.md
          else
            printf '%s\n\n%s' "$ENTRY" "$(cat CHANGELOG.md)" > CHANGELOG.md
          fi

      - name: Commit and tag
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git rm -r --ignore-unmatch test-marketplace
          git add .codex-plugin/plugin.json CHANGELOG.md
          git commit -m "release: bump version to v${{ steps.version.outputs.new_version }}"
          git tag "v${{ steps.version.outputs.new_version }}"
          git push origin main
          git push origin "v${{ steps.version.outputs.new_version }}"

      - name: Create GitHub release
        run: |
          gh release create "v${{ steps.version.outputs.new_version }}" \
            --title "Release v${{ steps.version.outputs.new_version }}" \
            --generate-notes
        env:
          GH_TOKEN: ${{ github.token }}

SHA-256: 3c43b2f05e0139fe2530a2d0a043ad6735777292c9d637363d24ea7ae546c282