Skip to content

Commit e286298

Browse files
ci(ipa): use release tags for IPA ruleset (#889)
1 parent 900c47b commit e286298

File tree

3 files changed

+49
-18
lines changed

3 files changed

+49
-18
lines changed

.github/workflows/ipa-changelog.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,23 @@ jobs:
3232
env:
3333
VERSION_BUMP: ${{ steps.version_check.outputs.version_changed }}
3434
run: |
35-
npm run gen-ipa-changelog
36-
37-
# Check for uncommitted changes specific to CHANGELOG.md
38-
uncommitted_changes=$(git status --porcelain | grep "CHANGELOG.md" || echo "")
39-
40-
diff_changelog=$(git diff -- tools/spectral/ipa/CHANGELOG.md || echo "")
35+
diff_changelog=$(git diff origin/main -- CHANGELOG.md || echo "")
36+
37+
echo "Changelog diff: ${diff_changelog}"
4138
42-
if [[ "${VERSION_BUMP}" == "false" && -n "${uncommitted_changes}" ]]; then
39+
if [[ "${VERSION_BUMP}" == "false" && -n "${diff_changelog}" ]]; then
4340
echo "Error: Changelog should only be updated alongside a version bump. Please restore the changelog."
4441
exit 1
4542
fi
46-
47-
if [[ "${VERSION_BUMP}" == "true" && -n "${diff_changelog}" ]]; then
48-
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."
43+
44+
npm run gen-ipa-changelog
45+
46+
# Check CHANGELOG.md is the generated changelog result
47+
uncommitted_changes=$(git status --porcelain | grep "CHANGELOG.md" || echo "")
48+
49+
if [[ "${VERSION_BUMP}" == "true" && -n "${uncommitted_changes}" ]]; then
50+
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."
4951
exit 1
5052
fi
51-
exit 0
53+
54+
exit 0

.github/workflows/ipa-release.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
type: boolean
99
required: false
1010
default: true
11+
use_existing_tag:
12+
description: 'Set value to `true` to use an existing tag for the release process, default is `false`'
13+
default: 'false'
1114
push:
1215
branches:
1316
- main
@@ -19,6 +22,7 @@ jobs:
1922
runs-on: ubuntu-latest
2023
outputs:
2124
version_changed: ${{ steps.version_check.outputs.version_changed }}
25+
current_version: ${{ steps.version_check.outputs.current_version }}
2226

2327
steps:
2428
- name: Checkout Repository
@@ -36,7 +40,31 @@ jobs:
3640
version_changed=$(./.github/scripts/ipa_version_check.sh)
3741
echo "Version changed? ${version_changed}"
3842
echo "version_changed=${version_changed}" >> "${GITHUB_OUTPUT}"
39-
43+
echo "current_version=${jq -r '.version' tools/spectral/ipa/package.json}" >> "${GITHUB_OUTPUT}"
44+
45+
create-tag:
46+
runs-on: ubuntu-latest
47+
needs: check-version
48+
if: >-
49+
!cancelled()
50+
&& inputs.use_existing_tag == 'false'
51+
steps:
52+
- name: Validation of version format
53+
run: |
54+
echo "${{ needs.check-version.outputs.current_version }}" | grep -P '^\d+\.\d+\.\d+$'
55+
- name: Checkout
56+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
57+
- name: Get the latest commit SHA
58+
id: get-sha
59+
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
60+
- name: Create release tag
61+
uses: rickstaa/action-create-tag@a1c7777fcb2fee4f19b0f283ba888afa11678b72
62+
with:
63+
tag: 'ipa-validation-ruleset-v${{ needs.check-version.outputs.current_version }}'
64+
commit_sha: ${{ steps.get-sha.outputs.sha }}
65+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
66+
gpg_passphrase: ${{ secrets.PASSPHRASE }}
67+
4068
publish:
4169
needs: check-version
4270
runs-on: ubuntu-latest

tools/spectral/ipa/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
"auto-changelog": "2.5.0"
3737
},
3838
"auto-changelog" : {
39-
"package" : true,
39+
"package": true,
4040
"commitPattern": "[a-z]+\\(ipa\\):",
41-
"startingVersion" : "0.0.1",
42-
"hideCredit": true,
43-
"tagPattern": "none",
41+
"startingVersion": "ipa-validation-ruleset-v1.0.0",
42+
"hideCredit": true,
43+
"tagPattern": "ipa-validation-ruleset-v\\d+\\.\\d+\\.\\d+",
44+
"tagPrefix": "ipa-validation-ruleset-v",
4445
"hideEmptyReleases" : true,
45-
"contributors": false,
46-
"changeCount": 0
46+
"contributors": false
4747
}
4848
}

0 commit comments

Comments
 (0)