Add github action to increment cargo version numbers when a release is published (#25821)
* Add github action to increment cargo version number when a release is published
This commit is contained in:
parent
b2b426d4bf
commit
3f47c83e5c
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue