-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add github action to increment cargo version numbers when a release i…
…s published (#25821) (#25853) * Add github action to increment cargo version number when a release is published (cherry picked from commit 3f47c83) Co-authored-by: Will Hickey <will.hickey@solana.com>
- Loading branch information
1 parent
165ee12
commit 837cf71
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: increment-cargo-version | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
check_compilation: | ||
name: Increment cargo version | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
# This script confirms two assumptions: | ||
# 1) Tag should be branch.<patch_version> | ||
# 2) Tag should match the crate version numbers in the manifest files (which get incremented by the next step) | ||
- name: Confirm tag, branch, and cargo version numbers | ||
run: scripts/confirm-cargo-version-numbers-before-bump.sh ${{ github.event.release.target_commitish }} ${{ github.event.release.tag_name }} | ||
|
||
- name: Update Patch Version Numbers | ||
run: | | ||
OUTPUT=$(scripts/increment-cargo-version.sh patch) | ||
SOLANA_NEW_VERSION=$(sed -E 's/.* -> //' <<< $OUTPUT) | ||
echo "SOLANA_NEW_VERSION=$SOLANA_NEW_VERSION" | ||
echo "SOLANA_NEW_VERSION=$SOLANA_NEW_VERSION" >> $GITHUB_ENV | ||
- name: Cargo Tree | ||
run: ./scripts/cargo-for-all-lock-files.sh tree | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v4 | ||
with: | ||
commit-message: Bump Version to ${{ env.SOLANA_NEW_VERSION }} | ||
title: Bump Version to ${{ env.SOLANA_NEW_VERSION }} | ||
body: PR opened by Github Action | ||
branch: update-version-${{ env.SOLANA_NEW_VERSION }} | ||
base: ${{ github.event.release.target_commitish }} | ||
labels: automerge |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
usage() { | ||
cat <<EOF | ||
usage: $0 branch tag | ||
Checks that the tag matches the branch and the Cargo.toml versions match the tag. | ||
EOF | ||
exit 0 | ||
} | ||
|
||
branch="$1" | ||
tag="$2" | ||
|
||
echo "branch: $branch tag: $tag" | ||
|
||
# The tag is expected to be the branch name plus a patch number. eg: | ||
# tag: v1.2.3 | ||
# branch: v1.2 | ||
if [[ "$tag" != "$branch"* ]]; then | ||
>&2 echo "Tag must start with the branch name. Tag: $tag Branch: $branch" | ||
exit 1 | ||
fi | ||
|
||
here="$(dirname "$0")" | ||
cd "$here"/.. | ||
source scripts/read-cargo-variable.sh | ||
|
||
ignores=( | ||
.cache | ||
.cargo | ||
target | ||
web3.js/examples | ||
web3.js/test | ||
node_modules | ||
) | ||
|
||
not_paths=() | ||
for ignore in "${ignores[@]}"; do | ||
not_paths+=(-not -path "*/$ignore/*") | ||
done | ||
|
||
# shellcheck disable=2207 | ||
Cargo_tomls=($(find . -mindepth 2 -name Cargo.toml "${not_paths[@]}")) | ||
|
||
for Cargo_toml in "${Cargo_tomls[@]}"; do | ||
manifest_version="$(readCargoVariable version "${Cargo_toml}")" | ||
if ! [[ "v$manifest_version" == "$tag" ]]; then | ||
>&2 echo "Tag must match the crate version in the manifest files. Mismatch found in $Cargo_toml. Tag: $tag Manifest version: $manifest_version" | ||
exit 1 | ||
else | ||
echo "tag matches manifest: $Cargo_toml $manifest_version $tag" | ||
fi | ||
done |