chore(deps): update dependency cargo-release to v0.25.16 #217
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- main | |
- hotfix/** | |
workflow_dispatch: | |
env: | |
BUMP_FILE: .version-bump | |
CARGO_TERM_COLOR: always | |
RUSTFLAGS: --deny warnings | |
# renovate: datasource=crate versioning=semver-coerced depName=cargo-release | |
VERSION_CARGO_RELEASE: 0.25.16 | |
# renovate: datasource=crate versioning=semver-coerced depName=cargo-workspaces | |
VERSION_CARGO_WORKSPACES: 0.3.6 | |
# renovate: datasource=crate versioning=semver-coerced depName=convco | |
VERSION_CONVCO: 0.6.1 | |
jobs: | |
ci: | |
name: CI | |
uses: ./.github/workflows/ci.yml | |
test: | |
name: Test | |
uses: ./.github/workflows/test.yml | |
release-merged: | |
name: Find merged release PR | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get merged PR | |
id: get-merged-pr | |
uses: actions-ecosystem/action-get-merged-pull-request@v1.0.1 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get release | |
id: release | |
if: contains(steps.get-merged-pr.outputs.labels, 'release:pending') | |
env: | |
BODY: ${{ steps.get-merged-pr.outputs.body }} | |
run: | | |
version=$(echo "$BODY" | sed -n 's/<!-- VERSION:\(.*\) -->/\1/p') | |
echo "Version: $version" | |
echo "version=$version" >> $GITHUB_OUTPUT | |
echo 'is-release=true' >> $GITHUB_OUTPUT | |
outputs: | |
is-release: ${{ steps.release.outputs.is-release }} | |
version: ${{ steps.release.outputs.version }} | |
pr-number: ${{ steps.get-merged-pr.outputs.number }} | |
update-pending-release: | |
name: Update pending release | |
runs-on: ubuntu-latest | |
needs: release-merged | |
if: ${{ !needs.release-merged.outputs.is-release }} | |
steps: | |
- name: Cache | |
id: cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/ | |
key: cargo-release-${{ env.VERSION_CARGO_RELEASE }}-convco-${{ env.VERSION_CONVCO }} | |
- name: Install `cargo-release` | |
if: ${{ !steps.cache.outputs.cache-hit }} | |
run: cargo install --locked cargo-release@${{ env.VERSION_CARGO_RELEASE }} | |
- name: Install `convco` | |
if: ${{ !steps.cache.outputs.cache-hit }} | |
run: cargo install --locked convco@${{ env.VERSION_CONVCO }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Determine version bump | |
id: bump | |
run: | | |
type=$(<"$BUMP_FILE") | |
case "$type" in | |
semantic) | |
level="$(convco version --bump --label)" ;; | |
major|minor|patch) | |
level="$type" ;; | |
*) | |
>&2 echo "Invalid version bump type '$type'" | |
exit 1 ;; | |
esac | |
echo "Version bump type: $type" | |
echo "Version bump level: $level" | |
echo "type=$type" >> $GITHUB_OUTPUT | |
echo "level=$level" >> $GITHUB_OUTPUT | |
- name: Check version bump level | |
if: startsWith(github.ref_name, 'hotfix/') | |
env: | |
LEVEL: ${{ steps.bump.outputs.level }} | |
run: | | |
case "$LEVEL" in | |
patch|release) | |
;; | |
*) | |
>&2 echo "Illegal version bump level '$LEVEL' for hotfix release" | |
exit 1 ;; | |
esac | |
- name: Check for release | |
id: check-release | |
env: | |
LEVEL: ${{ steps.bump.outputs.level }} | |
run: | | |
if [ "$LEVEL" != 'release' ]; then | |
echo 'found=true' >> $GITHUB_OUTPUT | |
fi | |
- name: cargo-release preparation | |
id: prepare-release | |
if: steps.check-release.outputs.found | |
run: | | |
git config user.name 'GitHub' | |
git config user.email 'noreply@github.com' | |
cat <<EOF > ~/.release.toml | |
pre-release-commit-message = "{{version}}" | |
EOF | |
- name: Run `cargo release` | |
if: steps.check-release.outputs.found | |
run: cargo release ${{ steps.bump.outputs.level }} --execute --no-confirm --no-publish --no-tag --no-push | |
- name: Determine version and reset commit | |
id: version | |
if: steps.check-release.outputs.found | |
run: | | |
version=$(git log --max-count=1 --pretty='format:%s') | |
git reset HEAD~ | |
echo "Version: $version" | |
echo "version=$version" >> $GITHUB_OUTPUT | |
- name: Reset version bump file | |
if: steps.check-release.outputs.found | |
run: echo 'semantic' > "$BUMP_FILE" | |
- name: Get release notes from changelog | |
id: release-notes | |
if: steps.check-release.outputs.found | |
shell: bash | |
env: | |
VERSION: ${{ steps.version.outputs.version }} | |
run: | | |
echo 'RELEASE_NOTES<<EOF' >> "$GITHUB_ENV" | |
./.github/workflows/release_notes.sh CHANGELOG.md "$VERSION" >> "$GITHUB_ENV" | |
echo 'EOF' >> "$GITHUB_ENV" | |
- name: Create pull request | |
if: steps.check-release.outputs.found | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
# use PAT instead of GITHUB_TOKEN so created PR can trigger workflows | |
# see https://github.com/peter-evans/create-pull-request/issues/48 | |
token: ${{ secrets.RELEASE_GITHUB_TOKEN }} | |
branch: release/${{ github.ref_name }} | |
author: Matthias Stemmler <matthias.stemmler@gmail.com> | |
commit-message: "chore: bump version to ${{ steps.version.outputs.version }}" | |
delete-branch: true | |
labels: release:pending | |
title: Release v${{ steps.version.outputs.version }} | |
body: | | |
<!-- VERSION:${{ steps.version.outputs.version }} --> | |
| Name | Value | | |
| ---------------------- | -------------------------------------------------- | | |
| **Version** | `${{ steps.version.outputs.version }}` | | |
| **Version bump type** | `${{ steps.bump.outputs.type }}` | | |
| **Version bump level** | `${{ steps.bump.outputs.level }}` | | |
| **Base branch** | `${{ github.ref_name }}` | | |
${{ env.RELEASE_NOTES }} | |
publish-release: | |
name: Publish release | |
runs-on: ubuntu-latest | |
needs: | |
- release-merged | |
- ci | |
- test | |
if: needs.release-merged.outputs.is-release | |
environment: crates.io | |
concurrency: production | |
steps: | |
- name: Cache | |
id: cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/ | |
key: cargo-workspaces-${{ env.VERSION_CARGO_WORKSPACES }} | |
- name: Install `cargo-workspaces` | |
if: ${{ !steps.cache.outputs.cache-hit }} | |
run: cargo install --locked cargo-workspaces@${{ env.VERSION_CARGO_WORKSPACES }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get release notes from changelog | |
id: release-notes | |
shell: bash | |
env: | |
VERSION: ${{ needs.release-merged.outputs.version }} | |
run: | | |
echo 'RELEASE_NOTES<<EOF' >> "$GITHUB_ENV" | |
./.github/workflows/release_notes.sh CHANGELOG.md "$VERSION" >> "$GITHUB_ENV" | |
echo 'EOF' >> "$GITHUB_ENV" | |
- name: Publish release | |
env: | |
TOKEN: ${{ secrets.CRATES_IO_TOKEN }} | |
run: | | |
output=$(cargo workspaces publish --yes --publish-as-is --token "$TOKEN" 2>&1) | |
echo "$output" | |
echo 'Crate URLs:' | |
echo 'CRATE_URLS<<EOF' >> "$GITHUB_ENV" | |
echo "$output" | sed -n 's/.*\bpublished \(.*\) v\(.*\)/- https:\/\/crates.io\/crates\/\1\/\2/p' | tac | tee --append "$GITHUB_ENV" | |
echo 'EOF' >> "$GITHUB_ENV" | |
- name: Create tag and GitHub release | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: v${{ needs.release-merged.outputs.version }} | |
tag_name: v${{ needs.release-merged.outputs.version }} | |
body: | | |
**Published crates:** | |
${{ env.CRATE_URLS }} | |
${{ env.RELEASE_NOTES }} | |
- name: Remove `release:pending` label from pull request | |
uses: actions-ecosystem/action-remove-labels@v1 | |
with: | |
number: ${{ needs.release-merged.outputs.pr-number }} | |
labels: release:pending | |
- name: Add `release:published` label to pull request | |
uses: actions-ecosystem/action-add-labels@v1 | |
with: | |
number: ${{ needs.release-merged.outputs.pr-number }} | |
labels: release:published |