|
39 | 39 | - name: Checkout code |
40 | 40 | uses: actions/checkout@v4 |
41 | 41 |
|
| 42 | + - name: Extract version from tag and update Cargo.toml |
| 43 | + shell: bash |
| 44 | + run: | |
| 45 | + VERSION=${GITHUB_REF#refs/tags/v} |
| 46 | + sed -i.bak "s/^version = \".*\"/version = \"${VERSION}\"/" Cargo.toml |
| 47 | + rm Cargo.toml.bak |
| 48 | +
|
42 | 49 | - name: Install Rust toolchain |
43 | 50 | uses: dtolnay/rust-toolchain@master |
44 | 51 | with: |
|
97 | 104 | uses: actions/checkout@v4 |
98 | 105 | with: |
99 | 106 | fetch-depth: 0 |
| 107 | + token: ${{ secrets.GITHUB_TOKEN }} |
100 | 108 |
|
101 | 109 | - name: Download all artifacts |
102 | 110 | uses: actions/download-artifact@v4 |
@@ -184,3 +192,32 @@ jobs: |
184 | 192 | checksums.txt |
185 | 193 | draft: false |
186 | 194 | prerelease: false |
| 195 | + |
| 196 | + - name: Checkout main branch |
| 197 | + run: | |
| 198 | + git config --global user.name "sshdb-release-bot" |
| 199 | + git config --global user.email "[email protected]" |
| 200 | + git checkout main || git checkout master |
| 201 | +
|
| 202 | + - name: Update Cargo.toml with release version |
| 203 | + run: | |
| 204 | + VERSION="${{ steps.tag.outputs.VERSION }}" |
| 205 | + sed -i.bak "s/^version = \".*\"/version = \"${VERSION}\"/" Cargo.toml |
| 206 | + rm Cargo.toml.bak |
| 207 | + git add Cargo.toml |
| 208 | + git commit -m "chore: update version to ${VERSION} for release" || echo "No changes to commit" |
| 209 | +
|
| 210 | + - name: Bump Cargo.toml to dev version |
| 211 | + run: | |
| 212 | + VERSION="${{ steps.tag.outputs.VERSION }}" |
| 213 | + sed -i.bak "s/^version = \".*\"/version = \"${VERSION}-dev\"/" Cargo.toml |
| 214 | + rm Cargo.toml.bak |
| 215 | + git add Cargo.toml |
| 216 | + git commit -m "chore: bump version to ${VERSION}-dev" || echo "No changes to commit" |
| 217 | +
|
| 218 | + - name: Push version updates |
| 219 | + env: |
| 220 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 221 | + run: | |
| 222 | + git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }} |
| 223 | + git push origin main || git push origin master |
0 commit comments