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_extension:
 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    - id: cache-zed-extension-cli
 37      name: extension_tests::cache_zed_extension_cli
 38      uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
 39      with:
 40        path: zed-extension
 41        key: zed-extension-${{ env.ZED_EXTENSION_CLI_SHA }}
 42    - name: extension_tests::download_zed_extension_cli
 43      if: steps.cache-zed-extension-cli.outputs.cache-hit != 'true'
 44      run: |
 45        wget --quiet "https://zed-extension-cli.nyc3.digitaloceanspaces.com/$ZED_EXTENSION_CLI_SHA/x86_64-unknown-linux-gnu/zed-extension"
 46        chmod +x zed-extension
 47      shell: bash -euxo pipefail {0}
 48    - name: extension_tests::check
 49      run: |
 50        mkdir -p /tmp/ext-scratch
 51        mkdir -p /tmp/ext-output
 52        ./zed-extension --source-dir . --scratch-dir /tmp/ext-scratch --output-dir /tmp/ext-output
 53      shell: bash -euxo pipefail {0}
 54    timeout-minutes: 2
 55  check_bump_needed:
 56    if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
 57    runs-on: namespace-profile-2x4-ubuntu-2404
 58    steps:
 59    - name: steps::checkout_repo
 60      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
 61      with:
 62        clean: false
 63        fetch-depth: 0
 64    - id: compare-versions-check
 65      name: extension_bump::compare_versions
 66      run: |
 67        CURRENT_VERSION="$(sed -n 's/version = \"\(.*\)\"/\1/p' < extension.toml)"
 68        PR_PARENT_SHA="${{ github.event.pull_request.head.sha }}"
 69
 70        if [[ -n "$PR_PARENT_SHA" ]]; then
 71            git checkout "$PR_PARENT_SHA"
 72        elif BRANCH_PARENT_SHA="$(git merge-base origin/main origin/zed-zippy-autobump)"; then
 73            git checkout "$BRANCH_PARENT_SHA"
 74        else
 75            git checkout "$(git log -1 --format=%H)"~1
 76        fi
 77
 78        PARENT_COMMIT_VERSION="$(sed -n 's/version = \"\(.*\)\"/\1/p' < extension.toml)"
 79
 80        [[ "$CURRENT_VERSION" == "$PARENT_COMMIT_VERSION" ]] && \
 81          echo "needs_bump=true" >> "$GITHUB_OUTPUT" || \
 82          echo "needs_bump=false" >> "$GITHUB_OUTPUT"
 83
 84        echo "current_version=${CURRENT_VERSION}" >> "$GITHUB_OUTPUT"
 85      shell: bash -euxo pipefail {0}
 86    outputs:
 87      needs_bump: ${{ steps.compare-versions-check.outputs.needs_bump }}
 88      current_version: ${{ steps.compare-versions-check.outputs.current_version }}
 89    timeout-minutes: 1
 90  bump_extension_version:
 91    needs:
 92    - check_extension
 93    - check_bump_needed
 94    if: |-
 95      (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') &&
 96      (inputs.force-bump == 'true' || needs.check_bump_needed.outputs.needs_bump == 'true')
 97    runs-on: namespace-profile-8x16-ubuntu-2204
 98    steps:
 99    - id: generate-token
100      name: extension_bump::generate_token
101      uses: actions/create-github-app-token@v2
102      with:
103        app-id: ${{ secrets.app-id }}
104        private-key: ${{ secrets.app-secret }}
105    - name: steps::checkout_repo
106      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
107      with:
108        clean: false
109    - name: extension_bump::install_bump_2_version
110      run: pip install bump2version
111      shell: bash -euxo pipefail {0}
112    - id: bump-version
113      name: extension_bump::bump_version
114      run: |
115        OLD_VERSION="${{ needs.check_bump_needed.outputs.current_version }}"
116
117        cat <<EOF > .bumpversion.cfg
118        [bumpversion]
119        current_version = "$OLD_VERSION"
120
121        [bumpversion:file:Cargo.toml]
122
123        [bumpversion:file:extension.toml]
124
125        EOF
126
127        bump2version --verbose ${{ inputs.bump-type }}
128        NEW_VERSION="$(sed -n 's/version = \"\(.*\)\"/\1/p' < extension.toml)"
129        cargo update --workspace
130
131        rm .bumpversion.cfg
132
133        echo "new_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
134      shell: bash -euxo pipefail {0}
135    - name: extension_bump::create_pull_request
136      uses: peter-evans/create-pull-request@v7
137      with:
138        title: Bump version to ${{ steps.bump-version.outputs.new_version }}
139        body: This PR bumps the version of this extension to v${{ steps.bump-version.outputs.new_version }}
140        commit-message: Bump version to v${{ steps.bump-version.outputs.new_version }}
141        branch: zed-zippy-autobump
142        committer: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
143        base: main
144        delete-branch: true
145        token: ${{ steps.generate-token.outputs.token }}
146        sign-commits: true
147    timeout-minutes: 1
148  create_version_label:
149    needs:
150    - check_extension
151    - check_bump_needed
152    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'
153    runs-on: namespace-profile-8x16-ubuntu-2204
154    steps:
155    - id: generate-token
156      name: extension_bump::generate_token
157      uses: actions/create-github-app-token@v2
158      with:
159        app-id: ${{ secrets.app-id }}
160        private-key: ${{ secrets.app-secret }}
161    - name: steps::checkout_repo
162      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
163      with:
164        clean: false
165    - name: extension_bump::create_version_tag
166      uses: actions/github-script@v7
167      with:
168        script: |-
169          github.rest.git.createRef({
170              owner: context.repo.owner,
171              repo: context.repo.repo,
172              ref: 'refs/tags/v${{ needs.check_bump_needed.outputs.current_version }}',
173              sha: context.sha
174          })
175        github-token: ${{ steps.generate-token.outputs.token }}
176    timeout-minutes: 1
177concurrency:
178  group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
179  cancel-in-progress: true