extension_bump.yml

  1# Generated from xtask::workflows::extension_bump
  2# Rebuild with `cargo xtask workflows`.
  3name: extension_bump
  4env:
  5  CARGO_TERM_COLOR: always
  6  RUST_BACKTRACE: '1'
  7  CARGO_INCREMENTAL: '0'
  8  ZED_EXTENSION_CLI_SHA: 7cfce605704d41ca247e3f84804bf323f6c6caaf
  9on:
 10  workflow_call:
 11    inputs:
 12      bump-type:
 13        description: bump-type
 14        type: string
 15        default: patch
 16      force-bump:
 17        description: force-bump
 18        required: true
 19        type: boolean
 20    secrets:
 21      app-id:
 22        description: The app ID used to create the PR
 23        required: true
 24      app-secret:
 25        description: The app secret for the corresponding app ID
 26        required: true
 27jobs:
 28  check_bump_needed:
 29    if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
 30    runs-on: namespace-profile-2x4-ubuntu-2404
 31    steps:
 32    - name: steps::checkout_repo
 33      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
 34      with:
 35        clean: false
 36        fetch-depth: 0
 37    - id: compare-versions-check
 38      name: extension_bump::compare_versions
 39      run: |
 40        CURRENT_VERSION="$(sed -n 's/version = \"\(.*\)\"/\1/p' < extension.toml)"
 41        PR_PARENT_SHA="${{ github.event.pull_request.head.sha }}"
 42
 43        if [[ -n "$PR_PARENT_SHA" ]]; then
 44            git checkout "$PR_PARENT_SHA"
 45        elif BRANCH_PARENT_SHA="$(git merge-base origin/main origin/zed-zippy-autobump)"; then
 46            git checkout "$BRANCH_PARENT_SHA"
 47        else
 48            git checkout "$(git log -1 --format=%H)"~1
 49        fi
 50
 51        PARENT_COMMIT_VERSION="$(sed -n 's/version = \"\(.*\)\"/\1/p' < extension.toml)"
 52
 53        [[ "$CURRENT_VERSION" == "$PARENT_COMMIT_VERSION" ]] && \
 54          echo "needs_bump=true" >> "$GITHUB_OUTPUT" || \
 55          echo "needs_bump=false" >> "$GITHUB_OUTPUT"
 56
 57        echo "current_version=${CURRENT_VERSION}" >> "$GITHUB_OUTPUT"
 58      shell: bash -euxo pipefail {0}
 59    outputs:
 60      needs_bump: ${{ steps.compare-versions-check.outputs.needs_bump }}
 61      current_version: ${{ steps.compare-versions-check.outputs.current_version }}
 62    timeout-minutes: 1
 63  bump_extension_version:
 64    needs:
 65    - check_bump_needed
 66    if: |-
 67      (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') &&
 68      (inputs.force-bump == 'true' || needs.check_bump_needed.outputs.needs_bump == 'true')
 69    runs-on: namespace-profile-8x16-ubuntu-2204
 70    steps:
 71    - id: generate-token
 72      name: extension_bump::generate_token
 73      uses: actions/create-github-app-token@v2
 74      with:
 75        app-id: ${{ secrets.app-id }}
 76        private-key: ${{ secrets.app-secret }}
 77    - name: steps::checkout_repo
 78      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
 79      with:
 80        clean: false
 81    - name: extension_bump::install_bump_2_version
 82      run: pip install bump2version
 83      shell: bash -euxo pipefail {0}
 84    - id: bump-version
 85      name: extension_bump::bump_version
 86      run: |
 87        OLD_VERSION="${{ needs.check_bump_needed.outputs.current_version }}"
 88
 89        BUMP_FILES=("extension.toml")
 90        if [[ -f "Cargo.toml" ]]; then
 91            BUMP_FILES+=("Cargo.toml")
 92        fi
 93
 94        bump2version --verbose --current-version "$OLD_VERSION" --no-configured-files ${{ inputs.bump-type }} "${BUMP_FILES[@]}"
 95
 96        if [[ -f "Cargo.toml" ]]; then
 97            cargo update --workspace
 98        fi
 99
100        NEW_VERSION="$(sed -n 's/version = \"\(.*\)\"/\1/p' < extension.toml)"
101
102        echo "new_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
103      shell: bash -euxo pipefail {0}
104    - name: extension_bump::create_pull_request
105      uses: peter-evans/create-pull-request@v7
106      with:
107        title: Bump version to ${{ steps.bump-version.outputs.new_version }}
108        body: This PR bumps the version of this extension to v${{ steps.bump-version.outputs.new_version }}
109        commit-message: Bump version to v${{ steps.bump-version.outputs.new_version }}
110        branch: zed-zippy-autobump
111        committer: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
112        base: main
113        delete-branch: true
114        token: ${{ steps.generate-token.outputs.token }}
115        sign-commits: true
116    timeout-minutes: 1
117  create_version_label:
118    needs:
119    - check_bump_needed
120    if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') && github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.check_bump_needed.outputs.needs_bump == 'false'
121    runs-on: namespace-profile-8x16-ubuntu-2204
122    steps:
123    - id: generate-token
124      name: extension_bump::generate_token
125      uses: actions/create-github-app-token@v2
126      with:
127        app-id: ${{ secrets.app-id }}
128        private-key: ${{ secrets.app-secret }}
129    - name: steps::checkout_repo
130      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
131      with:
132        clean: false
133    - name: extension_bump::create_version_tag
134      uses: actions/github-script@v7
135      with:
136        script: |-
137          github.rest.git.createRef({
138              owner: context.repo.owner,
139              repo: context.repo.repo,
140              ref: 'refs/tags/v${{ needs.check_bump_needed.outputs.current_version }}',
141              sha: context.sha
142          })
143        github-token: ${{ steps.generate-token.outputs.token }}
144    timeout-minutes: 1
145concurrency:
146  group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
147  cancel-in-progress: true