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: 03d8e9aee95ea6117d75a48bcac2e19241f6e667
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 working-directory:
21 description: working-directory
22 type: string
23 default: .
24 secrets:
25 app-id:
26 description: The app ID used to create the PR
27 required: true
28 app-secret:
29 description: The app secret for the corresponding app ID
30 required: true
31jobs:
32 check_version_changed:
33 if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
34 runs-on: namespace-profile-2x4-ubuntu-2404
35 steps:
36 - name: steps::checkout_repo
37 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
38 with:
39 clean: false
40 fetch-depth: 0
41 - id: compare-versions-check
42 name: extension_bump::compare_versions
43 run: |
44 CURRENT_VERSION="$(sed -n 's/^version = \"\(.*\)\"/\1/p' < extension.toml | tr -d '[:space:]')"
45
46 if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
47 PR_FORK_POINT="$(git merge-base origin/main HEAD)"
48 git checkout "$PR_FORK_POINT"
49 else
50 git checkout "$(git log -1 --format=%H)"~1
51 fi
52
53 PARENT_COMMIT_VERSION="$(sed -n 's/^version = \"\(.*\)\"/\1/p' < extension.toml | tr -d '[:space:]')"
54
55 [[ "$CURRENT_VERSION" == "$PARENT_COMMIT_VERSION" ]] && \
56 echo "version_changed=false" >> "$GITHUB_OUTPUT" || \
57 echo "version_changed=true" >> "$GITHUB_OUTPUT"
58
59 echo "current_version=${CURRENT_VERSION}" >> "$GITHUB_OUTPUT"
60 outputs:
61 version_changed: ${{ steps.compare-versions-check.outputs.version_changed }}
62 current_version: ${{ steps.compare-versions-check.outputs.current_version }}
63 timeout-minutes: 1
64 defaults:
65 run:
66 shell: bash -euxo pipefail {0}
67 working-directory: ${{ inputs.working-directory }}
68 bump_extension_version:
69 needs:
70 - check_version_changed
71 if: |-
72 (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') &&
73 (inputs.force-bump == true || needs.check_version_changed.outputs.version_changed == 'false')
74 runs-on: namespace-profile-2x4-ubuntu-2404
75 steps:
76 - id: generate-token
77 name: extension_bump::generate_token
78 uses: actions/create-github-app-token@v2
79 with:
80 app-id: ${{ secrets.app-id }}
81 private-key: ${{ secrets.app-secret }}
82 - name: steps::checkout_repo
83 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
84 with:
85 clean: false
86 - name: steps::cache_rust_dependencies_namespace
87 uses: namespacelabs/nscloud-cache-action@v1
88 with:
89 cache: rust
90 path: ~/.rustup
91 - name: extension_bump::install_bump_2_version
92 run: pip install bump2version --break-system-packages
93 - id: bump-version
94 name: extension_bump::bump_version
95 run: |
96 BUMP_FILES=("extension.toml")
97 if [[ -f "Cargo.toml" ]]; then
98 BUMP_FILES+=("Cargo.toml")
99 fi
100
101 bump2version \
102 --search "version = \"{current_version}"\" \
103 --replace "version = \"{new_version}"\" \
104 --current-version "$OLD_VERSION" \
105 --no-configured-files "$BUMP_TYPE" "${BUMP_FILES[@]}"
106
107 if [[ -f "Cargo.toml" ]]; then
108 cargo update --workspace
109 fi
110
111 NEW_VERSION="$(sed -n 's/^version = \"\(.*\)\"/\1/p' < extension.toml | tr -d '[:space:]')"
112 EXTENSION_ID="$(sed -n 's/^id = "\(.*\)"/\1/p' < extension.toml | head -1 | tr -d '[:space:]')"
113 EXTENSION_NAME="$(sed -n 's/^name = "\(.*\)"/\1/p' < extension.toml | head -1 | tr -d '[:space:]')"
114
115 if [[ "$WORKING_DIR" == "." || -z "$WORKING_DIR" ]]; then
116 {
117 echo "title=Bump version to ${NEW_VERSION}";
118 echo "body=This PR bumps the version of this extension to v${NEW_VERSION}";
119 echo "branch_name=zed-zippy-autobump";
120 } >> "$GITHUB_OUTPUT"
121 else
122 {
123 echo "title=${EXTENSION_ID}: Bump to v${NEW_VERSION}";
124 echo "body<<EOF";
125 echo "This PR bumps the version of the ${EXTENSION_NAME} extension to v${NEW_VERSION}.";
126 echo "";
127 echo "Release Notes:";
128 echo "";
129 echo "- N/A";
130 echo "EOF";
131 echo "branch_name=zed-zippy-${EXTENSION_ID}-autobump";
132 } >> "$GITHUB_OUTPUT"
133 fi
134
135 echo "new_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
136 env:
137 OLD_VERSION: ${{ needs.check_version_changed.outputs.current_version }}
138 BUMP_TYPE: ${{ inputs.bump-type }}
139 WORKING_DIR: ${{ inputs.working-directory }}
140 - name: extension_bump::create_pull_request
141 uses: peter-evans/create-pull-request@v7
142 with:
143 title: ${{ steps.bump-version.outputs.title }}
144 body: ${{ steps.bump-version.outputs.body }}
145 commit-message: ${{ steps.bump-version.outputs.title }}
146 branch: ${{ steps.bump-version.outputs.branch_name }}
147 committer: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
148 base: main
149 delete-branch: true
150 token: ${{ steps.generate-token.outputs.token }}
151 sign-commits: true
152 assignees: ${{ github.actor }}
153 timeout-minutes: 5
154 defaults:
155 run:
156 shell: bash -euxo pipefail {0}
157 working-directory: ${{ inputs.working-directory }}
158 create_version_label:
159 needs:
160 - check_version_changed
161 if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') && github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.check_version_changed.outputs.version_changed == 'true'
162 runs-on: namespace-profile-2x4-ubuntu-2404
163 steps:
164 - id: generate-token
165 name: extension_bump::generate_token
166 uses: actions/create-github-app-token@v2
167 with:
168 app-id: ${{ secrets.app-id }}
169 private-key: ${{ secrets.app-secret }}
170 - name: steps::checkout_repo
171 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
172 with:
173 clean: false
174 - id: determine-tag
175 name: extension_bump::determine_tag
176 run: |
177 EXTENSION_ID="$(sed -n 's/^id = "\(.*\)"/\1/p' < extension.toml | head -1 | tr -d '[:space:]')"
178
179 if [[ "$WORKING_DIR" == "." || -z "$WORKING_DIR" ]]; then
180 TAG="v${CURRENT_VERSION}"
181 else
182 TAG="${EXTENSION_ID}-v${CURRENT_VERSION}"
183 fi
184
185 echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
186 env:
187 CURRENT_VERSION: ${{ needs.check_version_changed.outputs.current_version }}
188 WORKING_DIR: ${{ inputs.working-directory }}
189 - name: extension_bump::create_version_tag
190 uses: actions/github-script@v7
191 with:
192 script: |-
193 github.rest.git.createRef({
194 owner: context.repo.owner,
195 repo: context.repo.repo,
196 ref: 'refs/tags/${{ steps.determine-tag.outputs.tag }}',
197 sha: context.sha
198 })
199 github-token: ${{ steps.generate-token.outputs.token }}
200 outputs:
201 tag: ${{ steps.determine-tag.outputs.tag }}
202 timeout-minutes: 1
203 defaults:
204 run:
205 shell: bash -euxo pipefail {0}
206 working-directory: ${{ inputs.working-directory }}
207 trigger_release:
208 needs:
209 - check_version_changed
210 - create_version_label
211 if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
212 runs-on: namespace-profile-2x4-ubuntu-2404
213 steps:
214 - id: generate-token
215 name: extension_bump::generate_token
216 uses: actions/create-github-app-token@v2
217 with:
218 app-id: ${{ secrets.app-id }}
219 private-key: ${{ secrets.app-secret }}
220 owner: zed-industries
221 repositories: extensions
222 - name: steps::checkout_repo
223 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
224 with:
225 clean: false
226 - id: get-extension-id
227 name: extension_bump::get_extension_id
228 run: |
229 EXTENSION_ID="$(sed -n 's/id = \"\(.*\)\"/\1/p' < extension.toml)"
230
231 echo "extension_id=${EXTENSION_ID}" >> "$GITHUB_OUTPUT"
232 - name: extension_bump::release_action
233 uses: zed-extensions/update-action@543925fc45da8866b0d017218a656c8a3296ed3f
234 with:
235 extension-name: ${{ steps.get-extension-id.outputs.extension_id }}
236 push-to: zed-industries/extensions
237 tag: ${{ needs.create_version_label.outputs.tag }}
238 env:
239 COMMITTER_TOKEN: ${{ steps.generate-token.outputs.token }}
240 defaults:
241 run:
242 shell: bash -euxo pipefail {0}
243 working-directory: ${{ inputs.working-directory }}
244concurrency:
245 group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}extension-bump
246 cancel-in-progress: true
247defaults:
248 run:
249 shell: bash -euxo pipefail {0}