diff --git a/.github/workflows/ipa-changelog.yml b/.github/workflows/ipa-changelog.yml index 2429cf639f..c016828dc8 100644 --- a/.github/workflows/ipa-changelog.yml +++ b/.github/workflows/ipa-changelog.yml @@ -32,20 +32,23 @@ jobs: env: VERSION_BUMP: ${{ steps.version_check.outputs.version_changed }} run: | - npm run gen-ipa-changelog - - # Check for uncommitted changes specific to CHANGELOG.md - uncommitted_changes=$(git status --porcelain | grep "CHANGELOG.md" || echo "") - - diff_changelog=$(git diff -- tools/spectral/ipa/CHANGELOG.md || echo "") + diff_changelog=$(git diff origin/main -- CHANGELOG.md || echo "") + + echo "Changelog diff: ${diff_changelog}" - if [[ "${VERSION_BUMP}" == "false" && -n "${uncommitted_changes}" ]]; then + if [[ "${VERSION_BUMP}" == "false" && -n "${diff_changelog}" ]]; then echo "Error: Changelog should only be updated alongside a version bump. Please restore the changelog." exit 1 fi - - if [[ "${VERSION_BUMP}" == "true" && -n "${diff_changelog}" ]]; then - echo "Error: Changelog must be updated alongside a version bump. Please run 'npm run gen-ipa-changelog' from the ipa directory and commit the changes." + + npm run gen-ipa-changelog + + # Check CHANGELOG.md is the generated changelog result + uncommitted_changes=$(git status --porcelain | grep "CHANGELOG.md" || echo "") + + if [[ "${VERSION_BUMP}" == "true" && -n "${uncommitted_changes}" ]]; then + echo "Error: Changelog is not the same as the generated result. Please run 'npm run gen-ipa-changelog' from the ipa directory and commit the changes." exit 1 fi - exit 0 \ No newline at end of file + + exit 0 diff --git a/.github/workflows/ipa-release.yml b/.github/workflows/ipa-release.yml index 5e4566a71f..1176f03057 100644 --- a/.github/workflows/ipa-release.yml +++ b/.github/workflows/ipa-release.yml @@ -8,6 +8,9 @@ on: type: boolean required: false default: true + use_existing_tag: + description: 'Set value to `true` to use an existing tag for the release process, default is `false`' + default: 'false' push: branches: - main @@ -19,6 +22,7 @@ jobs: runs-on: ubuntu-latest outputs: version_changed: ${{ steps.version_check.outputs.version_changed }} + current_version: ${{ steps.version_check.outputs.current_version }} steps: - name: Checkout Repository @@ -36,7 +40,31 @@ jobs: version_changed=$(./.github/scripts/ipa_version_check.sh) echo "Version changed? ${version_changed}" echo "version_changed=${version_changed}" >> "${GITHUB_OUTPUT}" - + echo "current_version=${jq -r '.version' tools/spectral/ipa/package.json}" >> "${GITHUB_OUTPUT}" + + create-tag: + runs-on: ubuntu-latest + needs: check-version + if: >- + !cancelled() + && inputs.use_existing_tag == 'false' + steps: + - name: Validation of version format + run: | + echo "${{ needs.check-version.outputs.current_version }}" | grep -P '^\d+\.\d+\.\d+$' + - name: Checkout + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - name: Get the latest commit SHA + id: get-sha + run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + - name: Create release tag + uses: rickstaa/action-create-tag@a1c7777fcb2fee4f19b0f283ba888afa11678b72 + with: + tag: 'ipa-validation-ruleset-v${{ needs.check-version.outputs.current_version }}' + commit_sha: ${{ steps.get-sha.outputs.sha }} + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + gpg_passphrase: ${{ secrets.PASSPHRASE }} + publish: needs: check-version runs-on: ubuntu-latest diff --git a/tools/spectral/ipa/package.json b/tools/spectral/ipa/package.json index 8fc5ff1de1..bbf8029a3b 100644 --- a/tools/spectral/ipa/package.json +++ b/tools/spectral/ipa/package.json @@ -36,13 +36,13 @@ "auto-changelog": "2.5.0" }, "auto-changelog" : { - "package" : true, + "package": true, "commitPattern": "[a-z]+\\(ipa\\):", - "startingVersion" : "0.0.1", - "hideCredit": true, - "tagPattern": "none", + "startingVersion": "ipa-validation-ruleset-v1.0.0", + "hideCredit": true, + "tagPattern": "ipa-validation-ruleset-v\\d+\\.\\d+\\.\\d+", + "tagPrefix": "ipa-validation-ruleset-v", "hideEmptyReleases" : true, - "contributors": false, - "changeCount": 0 + "contributors": false } }