|
| 1 | +name: Prepare Release (bump versions, tag, trigger release) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'New version (e.g. 0.0.2). If empty, patch is incremented from reference/PCF-v1.0/Cargo.toml.' |
| 8 | + required: false |
| 9 | + type: string |
| 10 | + dry_run: |
| 11 | + description: 'Pass dry_run=true to the triggered Release workflow (no actual registry publish).' |
| 12 | + required: false |
| 13 | + type: boolean |
| 14 | + default: false |
| 15 | + |
| 16 | +jobs: |
| 17 | + prepare: |
| 18 | + name: Bump versions and create release tag |
| 19 | + runs-on: ubuntu-latest |
| 20 | + permissions: |
| 21 | + contents: write |
| 22 | + actions: write |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 30 | + |
| 31 | + - name: Setup Node.js |
| 32 | + uses: actions/setup-node@v4 |
| 33 | + with: |
| 34 | + node-version: '22' |
| 35 | + |
| 36 | + - name: Determine new version |
| 37 | + id: version |
| 38 | + shell: bash |
| 39 | + run: | |
| 40 | + set -euo pipefail |
| 41 | + CURRENT=$(grep -m1 '^version = ' reference/PCF-v1.0/Cargo.toml | sed 's/.*"\(.*\)".*/\1/') |
| 42 | + if ! [[ "$CURRENT" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 43 | + echo "ERROR: Could not read a valid semver from reference/PCF-v1.0/Cargo.toml (got '$CURRENT')" |
| 44 | + exit 1 |
| 45 | + fi |
| 46 | +
|
| 47 | + INPUT='${{ github.event.inputs.version }}' |
| 48 | + if [ -n "$INPUT" ]; then |
| 49 | + NEW="$INPUT" |
| 50 | + if ! [[ "$NEW" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 51 | + echo "ERROR: Provided version '$NEW' is not a valid semantic version (expected X.Y.Z)" |
| 52 | + exit 1 |
| 53 | + fi |
| 54 | + else |
| 55 | + IFS='.' read -r MAJOR MINOR PATCH <<<"$CURRENT" |
| 56 | + NEW="$MAJOR.$MINOR.$((PATCH + 1))" |
| 57 | + fi |
| 58 | +
|
| 59 | + echo "current=$CURRENT" >> "$GITHUB_OUTPUT" |
| 60 | + echo "version=$NEW" >> "$GITHUB_OUTPUT" |
| 61 | + echo "Bumping $CURRENT -> $NEW" |
| 62 | +
|
| 63 | + - name: Refuse to retag existing version |
| 64 | + shell: bash |
| 65 | + run: | |
| 66 | + if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then |
| 67 | + echo "ERROR: tag v${{ steps.version.outputs.version }} already exists" |
| 68 | + exit 1 |
| 69 | + fi |
| 70 | +
|
| 71 | + - name: Bump Rust Cargo.toml files |
| 72 | + shell: bash |
| 73 | + run: | |
| 74 | + set -euo pipefail |
| 75 | + NEW='${{ steps.version.outputs.version }}' |
| 76 | + sed -i 's/^version = "[^"]*"/version = "'"$NEW"'"/' reference/PCF-v1.0/Cargo.toml |
| 77 | + sed -i 's/^version = "[^"]*"/version = "'"$NEW"'"/' reference/PFS-MS-v1.0/Cargo.toml |
| 78 | + sed -i 's/^version = "[^"]*"/version = "'"$NEW"'"/' tools/pcf-debug/Cargo.toml |
| 79 | + # path-dep version pins on pcf |
| 80 | + sed -i 's|pcf = { path = "\.\./PCF-v1.0", version = "[^"]*" }|pcf = { path = "../PCF-v1.0", version = "'"$NEW"'" }|' reference/PFS-MS-v1.0/Cargo.toml |
| 81 | + sed -i 's|pcf = { path = "\.\./\.\./reference/PCF-v1.0", version = "[^"]*" }|pcf = { path = "../../reference/PCF-v1.0", version = "'"$NEW"'" }|' tools/pcf-debug/Cargo.toml |
| 82 | +
|
| 83 | + - name: Bump TypeScript package |
| 84 | + shell: bash |
| 85 | + working-directory: implementations/ts |
| 86 | + run: npm version '${{ steps.version.outputs.version }}' --no-git-tag-version --allow-same-version |
| 87 | + |
| 88 | + - name: Bump .NET Pcf.csproj |
| 89 | + shell: bash |
| 90 | + run: | |
| 91 | + NEW='${{ steps.version.outputs.version }}' |
| 92 | + sed -i 's|<Version>[^<]*</Version>|<Version>'"$NEW"'</Version>|' implementations/dotnet/src/Pcf/Pcf.csproj |
| 93 | +
|
| 94 | + - name: Show diff |
| 95 | + run: git --no-pager diff --stat && git --no-pager diff |
| 96 | + |
| 97 | + - name: Commit, tag and push |
| 98 | + shell: bash |
| 99 | + run: | |
| 100 | + set -euo pipefail |
| 101 | + NEW='${{ steps.version.outputs.version }}' |
| 102 | + git config user.name "github-actions[bot]" |
| 103 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 104 | + git add -A |
| 105 | + git commit -m "Bump version to v$NEW" |
| 106 | + git tag -a "v$NEW" -m "Release v$NEW" |
| 107 | + git push origin HEAD --follow-tags |
| 108 | +
|
| 109 | + - name: Trigger Release workflow |
| 110 | + env: |
| 111 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 112 | + run: | |
| 113 | + gh workflow run release.yml \ |
| 114 | + --ref "v${{ steps.version.outputs.version }}" \ |
| 115 | + -f version='${{ steps.version.outputs.version }}' \ |
| 116 | + -f dry_run='${{ github.event.inputs.dry_run }}' |
0 commit comments