Skip to content

Apply suggestions from code review #1

Apply suggestions from code review

Apply suggestions from code review #1

Workflow file for this run

name: Bump Version
on:
workflow_dispatch:
inputs:
type:
description: 'release or hotfix'
type: choice
options:
- release
- hotfix
required: true
default: 'release'
version:
description: 'Version'
required: true
jobs:
release:
runs-on: ubuntu-latest
env:
# Crates from which the version will be bumped
CRATES: './aptos/aptos-programs,./aptos/core,./aptos/light-client,./aptos/programs/inclusion,./aptos/programs/epoch-change,./aptos/proof-server'
steps:
- name: Checkout code
uses: actions/checkout@v4
# Regex from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
- name: Validate version
run: |
echo "Validating version ${{ github.event.inputs.version }}..."
D='0|[1-9][0-9]*'
PW='[0-9]*[a-zA-Z-][0-9a-zA-Z-]*'
MW='[0-9a-zA-Z-]+'
if [[ "${{ github.event.inputs.version }}" =~ ^($D)\.($D)\.($D)(-(($D|$PW)(\.($D|$PW))*))?(\+($MW(\.$MW)*))?$ ]]; then
echo "Version ${{ github.event.inputs.version }} is valid."
else
echo "Version is not valid SemVer. Aborting..."
exit 1
fi
- name: Update version in Cargo.toml
run: |
echo "Updating version in Cargo.toml..."
IFS=',' read -ra CRATE_PATHS <<< "$CRATES"
for path in "${CRATE_PATHS[@]}"; do
cd $path
OLD_VERSION=$(grep -oP 'version = "\K[^"]+' Cargo.toml)
if [[ "${{ inputs.version }}" > "$OLD_VERSION" ]]; then
sed -i 's/version = "'$OLD_VERSION'"/version = "${{ inputs.version }}"/' Cargo.toml
else
echo "New version is not greater than the current version for $path. Aborting..."
exit 1
fi
cd $GITHUB_WORKSPACE
done
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
title: "${{ inputs.type == 'release' && 'Release' || 'Hotfix' }} ${{ inputs.version }}"
branch: "${{ inputs.type }}/${{ inputs.version }}"
commit-message: "${{ inputs.type == 'release' && 'feat' || 'fix' }}: bump version to ${{ inputs.version }}"
base: "${{ inputs.type == 'hotfix' && 'release/${{ inputs.version }}' || 'dev' }}:

Check failure on line 64 in .github/workflows/bump-version-PR.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/bump-version-PR.yml

Invalid workflow file

You have an error in your yaml syntax on line 64