|
| 1 | +name: Update GovTool Version and Changelog |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: "New version (e.g., 1.0.0)" |
| 8 | + required: true |
| 9 | + |
| 10 | +jobs: |
| 11 | + update-version: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout Repository |
| 16 | + uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + |
| 20 | + - name: Set up Node.js |
| 21 | + uses: actions/setup-node@v4 |
| 22 | + with: |
| 23 | + registry-url: "https://registry.npmjs.org/" |
| 24 | + node-version-file: "./govtool/frontend/.nvmrc" |
| 25 | + scope: "@intersect.mbo" |
| 26 | + |
| 27 | + - name: Set Version Variable |
| 28 | + run: echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV |
| 29 | + |
| 30 | + - name: Update package.json files and install dependencies |
| 31 | + run: | |
| 32 | + jq --arg v "$VERSION" '.version = $v' govtool/frontend/package.json > temp.json && mv temp.json govtool/frontend/package.json |
| 33 | + jq --arg v "$VERSION" '.version = $v' govtool/metadata-validation/package.json > temp.json && mv temp.json govtool/metadata-validation/package.json |
| 34 | +
|
| 35 | + echo "Running npm install to update lock files..." |
| 36 | + cd govtool/frontend && npm install && cd ../.. |
| 37 | + cd govtool/metadata-validation && npm install && cd ../.. |
| 38 | +
|
| 39 | + - name: Update vva-be.cabal version (Preserve Spacing) |
| 40 | + run: | |
| 41 | + sed -i -E "s/^(version:[[:space:]]+)[0-9]+\.[0-9]+\.[0-9]+/\1$VERSION/" govtool/backend/vva-be.cabal |
| 42 | + echo "✅ Updated version in vva-be.cabal while preserving spacing." |
| 43 | +
|
| 44 | + - name: Update Dockerfile Versions |
| 45 | + run: | |
| 46 | + sed -i -E "s/vva-be-[0-9]+\.[0-9]+\.[0-9]+/vva-be-$VERSION/g" govtool/backend/Dockerfile |
| 47 | + sed -i -E "s/vva-be-[0-9]+\.[0-9]+\.[0-9]+/vva-be-$VERSION/g" govtool/backend/Dockerfile.qovery |
| 48 | + echo "✅ Updated vva-be version in Dockerfiles." |
| 49 | +
|
| 50 | + - name: Update Metadata Validation API Version |
| 51 | + run: | |
| 52 | + sed -i -E "s/(\.setVersion\()[\"'][0-9]+\.[0-9]+\.[0-9]+[\"']/\1\"$VERSION\"/" govtool/metadata-validation/src/main.ts |
| 53 | + echo "✅ Updated API version in main.ts" |
| 54 | +
|
| 55 | + - name: Update CHANGELOG.md |
| 56 | + run: | |
| 57 | + #!/bin/bash |
| 58 | + VERSION="${{ github.event.inputs.version }}" |
| 59 | + TODAY=$(date +%Y-%m-%d) |
| 60 | + RELEASE_TAG="v$VERSION" |
| 61 | + RELEASE_LINK="[v$VERSION](https://github.com/IntersectMBO/govtool/releases/tag/$RELEASE_TAG)" |
| 62 | + TEMP_FILE=$(mktemp) |
| 63 | +
|
| 64 | + echo "Updating CHANGELOG.md with version $VERSION and date $TODAY..." |
| 65 | +
|
| 66 | + awk -v rl="$RELEASE_LINK" -v td="$TODAY" ' |
| 67 | + BEGIN { unreleased_found = 0; print_new_unreleased = 1 } |
| 68 | + { |
| 69 | + if ($1 == "##" && $2 == "[Unreleased]") { |
| 70 | + unreleased_found = 1 |
| 71 | +
|
| 72 | + # Print the new Unreleased section with required sub-sections |
| 73 | + print "## [Unreleased]\n" |
| 74 | + print "### Added\n" |
| 75 | + print "### Fixed\n" |
| 76 | + print "### Changed\n" |
| 77 | + print "### Removed\n" |
| 78 | +
|
| 79 | + # Rename the old Unreleased section with a version and date |
| 80 | + print "## " rl " " td "\n" |
| 81 | + next |
| 82 | + } |
| 83 | + print |
| 84 | + }' CHANGELOG.md > "$TEMP_FILE" |
| 85 | +
|
| 86 | + mv "$TEMP_FILE" CHANGELOG.md |
| 87 | +
|
| 88 | + echo "✅ CHANGELOG.md updated successfully!" |
| 89 | +
|
| 90 | + - name: Create Pull Request |
| 91 | + uses: peter-evans/create-pull-request@v7 |
| 92 | + with: |
| 93 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + branch: "chore/update-govtool-to-v${{ github.event.inputs.version }}" |
| 95 | + title: "Update GovTool to v${{ github.event.inputs.version }}" |
| 96 | + commit-message: "chore: update GovTool to v${{ github.event.inputs.version }}" |
| 97 | + body: | |
| 98 | + This PR updates GovTool to version `${{ github.event.inputs.version }}`. |
| 99 | +
|
| 100 | +
|
| 101 | + Workflow executed by `@${{ github.actor }}`. |
| 102 | + sign-commits: true |
0 commit comments