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 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 outputs:
59 needs_bump: ${{ steps.compare-versions-check.outputs.needs_bump }}
60 current_version: ${{ steps.compare-versions-check.outputs.current_version }}
61 timeout-minutes: 1
62 bump_extension_version:
63 needs:
64 - check_bump_needed
65 if: |-
66 (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') &&
67 (inputs.force-bump == 'true' || needs.check_bump_needed.outputs.needs_bump == 'true')
68 runs-on: namespace-profile-2x4-ubuntu-2404
69 steps:
70 - id: generate-token
71 name: extension_bump::generate_token
72 uses: actions/create-github-app-token@v2
73 with:
74 app-id: ${{ secrets.app-id }}
75 private-key: ${{ secrets.app-secret }}
76 - name: steps::checkout_repo
77 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
78 with:
79 clean: false
80 - name: extension_bump::install_bump_2_version
81 run: pip install bump2version --break-system-packages
82 - id: bump-version
83 name: extension_bump::bump_version
84 run: |
85 OLD_VERSION="${{ needs.check_bump_needed.outputs.current_version }}"
86
87 BUMP_FILES=("extension.toml")
88 if [[ -f "Cargo.toml" ]]; then
89 BUMP_FILES+=("Cargo.toml")
90 fi
91
92 bump2version \
93 --search "version = \"{current_version}"\" \
94 --replace "version = \"{new_version}"\" \
95 --current-version "$OLD_VERSION" \
96 --no-configured-files ${{ inputs.bump-type }} "${BUMP_FILES[@]}"
97
98 if [[ -f "Cargo.toml" ]]; then
99 cargo update --workspace
100 fi
101
102 NEW_VERSION="$(sed -n 's/version = \"\(.*\)\"/\1/p' < extension.toml)"
103
104 echo "new_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
105 - name: extension_bump::create_pull_request
106 uses: peter-evans/create-pull-request@v7
107 with:
108 title: Bump version to ${{ steps.bump-version.outputs.new_version }}
109 body: This PR bumps the version of this extension to v${{ steps.bump-version.outputs.new_version }}
110 commit-message: Bump version to v${{ steps.bump-version.outputs.new_version }}
111 branch: zed-zippy-autobump
112 committer: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
113 base: main
114 delete-branch: true
115 token: ${{ steps.generate-token.outputs.token }}
116 sign-commits: true
117 assignees: ${{ github.actor }}
118 timeout-minutes: 1
119 create_version_label:
120 needs:
121 - check_bump_needed
122 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'
123 runs-on: namespace-profile-2x4-ubuntu-2404
124 steps:
125 - id: generate-token
126 name: extension_bump::generate_token
127 uses: actions/create-github-app-token@v2
128 with:
129 app-id: ${{ secrets.app-id }}
130 private-key: ${{ secrets.app-secret }}
131 - name: steps::checkout_repo
132 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
133 with:
134 clean: false
135 - name: extension_bump::create_version_tag
136 uses: actions/github-script@v7
137 with:
138 script: |-
139 github.rest.git.createRef({
140 owner: context.repo.owner,
141 repo: context.repo.repo,
142 ref: 'refs/tags/v${{ needs.check_bump_needed.outputs.current_version }}',
143 sha: context.sha
144 })
145 github-token: ${{ steps.generate-token.outputs.token }}
146 timeout-minutes: 1
147concurrency:
148 group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
149 cancel-in-progress: true
150defaults:
151 run:
152 shell: bash -euxo pipefail {0}