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    secrets:
 17      app-id:
 18        description: The app ID used to create the PR
 19        required: true
 20      app-secret:
 21        description: The app secret for the corresponding app ID
 22        required: true
 23jobs:
 24  check_extension:
 25    if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
 26    runs-on: namespace-profile-2x4-ubuntu-2404
 27    steps:
 28    - name: steps::checkout_repo
 29      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
 30      with:
 31        clean: false
 32    - id: cache-zed-extension-cli
 33      name: extension_tests::cache_zed_extension_cli
 34      uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
 35      with:
 36        path: zed-extension
 37        key: zed-extension-${{ env.ZED_EXTENSION_CLI_SHA }}
 38    - name: extension_tests::download_zed_extension_cli
 39      if: steps.cache-zed-extension-cli.outputs.cache-hit != 'true'
 40      run: |
 41        wget --quiet "https://zed-extension-cli.nyc3.digitaloceanspaces.com/$ZED_EXTENSION_CLI_SHA/x86_64-unknown-linux-gnu/zed-extension"
 42        chmod +x zed-extension
 43      shell: bash -euxo pipefail {0}
 44    - name: extension_tests::check
 45      run: |
 46        mkdir -p /tmp/ext-scratch
 47        mkdir -p /tmp/ext-output
 48        ./zed-extension --source-dir . --scratch-dir /tmp/ext-scratch --output-dir /tmp/ext-output
 49      shell: bash -euxo pipefail {0}
 50    timeout-minutes: 1
 51  check_bump_needed:
 52    if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
 53    runs-on: namespace-profile-2x4-ubuntu-2404
 54    steps:
 55    - name: steps::checkout_repo
 56      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
 57      with:
 58        clean: false
 59        fetch-depth: 10
 60    - id: compare-versions-check
 61      name: extension_bump::compare_versions
 62      run: |+
 63        CURRENT_VERSION="$(sed -n 's/version = \"\(.*\)\"/\1/p' < extension.toml)"
 64
 65        git checkout "$(git log -1 --format=%H)"~1
 66
 67        PREV_COMMIT_VERSION="$(sed -n 's/version = \"\(.*\)\"/\1/p' < extension.toml)"
 68
 69        [[ "$CURRENT_VERSION" == "$PREV_COMMIT_VERSION" ]] && \
 70          echo "needs_bump=true" >> "$GITHUB_OUTPUT" || \
 71          echo "needs_bump=false" >> "$GITHUB_OUTPUT"
 72
 73      shell: bash -euxo pipefail {0}
 74    outputs:
 75      needs_bump: ${{ steps.compare-versions-check.outputs.needs_bump }}
 76    timeout-minutes: 1
 77  bump_extension_version:
 78    needs:
 79    - check_extension
 80    - check_bump_needed
 81    if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') && needs.check_bump_needed.outputs.needs_bump == 'true'
 82    runs-on: namespace-profile-8x16-ubuntu-2204
 83    steps:
 84    - id: generate-token
 85      name: extension_bump::generate_token
 86      uses: actions/create-github-app-token@v2
 87      with:
 88        app-id: ${{ secrets.app-id }}
 89        private-key: ${{ secrets.app-secret }}
 90    - name: steps::checkout_repo
 91      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
 92      with:
 93        clean: false
 94    - name: extension_bump::install_bump_2_version
 95      run: pip install bump2version
 96      shell: bash -euxo pipefail {0}
 97    - id: bump-version
 98      name: extension_bump::bump_version
 99      run: |
100        OLD_VERSION="$(sed -n 's/version = \"\(.*\)\"/\1/p' < extension.toml)"
101
102        cat <<EOF > .bumpversion.cfg
103        [bumpversion]
104        current_version = "$OLD_VERSION"
105
106        [bumpversion:file:Cargo.toml]
107
108        [bumpversion:file:extension.toml]
109
110        EOF
111
112        bump2version --verbose ${{ inputs.bump-type }}
113        NEW_VERSION="$(sed -n 's/version = \"\(.*\)\"/\1/p' < extension.toml)"
114        cargo update --workspace
115
116        rm .bumpversion.cfg
117
118        echo "old_version=${OLD_VERSION}" >> "$GITHUB_OUTPUT"
119        echo "new_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
120      shell: bash -euxo pipefail {0}
121    - name: extension_bump::create_pull_request
122      uses: peter-evans/create-pull-request@v7
123      with:
124        title: Bump version to ${{ steps.bump-version.outputs.new_version }}
125        body: This PR bumps the version of this extension to v${{ steps.bump-version.outputs.new_version }}
126        commit-message: Bump version to v${{ steps.bump-version.outputs.new_version }}
127        branch: bump-from-${{ steps.bump-version.outputs.old_version }}
128        committer: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
129        base: main
130        delete-branch: true
131        token: ${{ steps.generate-token.outputs.token }}
132        sign-commits: true
133    timeout-minutes: 1
134concurrency:
135  group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
136  cancel-in-progress: true