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 BUMP_FILES=("extension.toml")
118 if [[ -f "Cargo.toml" ]]; then
119 BUMP_FILES+=("Cargo.toml")
120 fi
121
122 bump2version --verbose --current-version "$OLD_VERSION" --no-configured-files ${{ inputs.bump-type }} "${BUMP_FILES[@]}"
123
124 if [[ -f "Cargo.toml" ]]; then
125 cargo update --workspace
126 fi
127
128 NEW_VERSION="$(sed -n 's/version = \"\(.*\)\"/\1/p' < extension.toml)"
129
130 echo "new_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
131 shell: bash -euxo pipefail {0}
132 - name: extension_bump::create_pull_request
133 uses: peter-evans/create-pull-request@v7
134 with:
135 title: Bump version to ${{ steps.bump-version.outputs.new_version }}
136 body: This PR bumps the version of this extension to v${{ steps.bump-version.outputs.new_version }}
137 commit-message: Bump version to v${{ steps.bump-version.outputs.new_version }}
138 branch: zed-zippy-autobump
139 committer: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
140 base: main
141 delete-branch: true
142 token: ${{ steps.generate-token.outputs.token }}
143 sign-commits: true
144 timeout-minutes: 1
145 create_version_label:
146 needs:
147 - check_extension
148 - check_bump_needed
149 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'
150 runs-on: namespace-profile-8x16-ubuntu-2204
151 steps:
152 - id: generate-token
153 name: extension_bump::generate_token
154 uses: actions/create-github-app-token@v2
155 with:
156 app-id: ${{ secrets.app-id }}
157 private-key: ${{ secrets.app-secret }}
158 - name: steps::checkout_repo
159 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
160 with:
161 clean: false
162 - name: extension_bump::create_version_tag
163 uses: actions/github-script@v7
164 with:
165 script: |-
166 github.rest.git.createRef({
167 owner: context.repo.owner,
168 repo: context.repo.repo,
169 ref: 'refs/tags/v${{ needs.check_bump_needed.outputs.current_version }}',
170 sha: context.sha
171 })
172 github-token: ${{ steps.generate-token.outputs.token }}
173 timeout-minutes: 1
174concurrency:
175 group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
176 cancel-in-progress: true