-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(GGM-30): add semantic release config
- Loading branch information
1 parent
aec9154
commit 6ead03c
Showing
3 changed files
with
357 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
name: Build and publish package to npm registry | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
release_tag: | ||
description: | | ||
'Version to manually release' | ||
required: true | ||
type: string | ||
dry_run: | ||
description: | | ||
'Dry run mode build but do not publish' | ||
type: boolean | ||
default: true | ||
workflow_call: | ||
inputs: | ||
release_tag: | ||
description: | | ||
'Version to manually release' | ||
required: true | ||
type: string | ||
dry_run: | ||
description: | | ||
'Dry run mode build but do not publish' | ||
type: boolean | ||
default: true | ||
|
||
permissions: | ||
id-token: write # required to use OIDC authentication | ||
contents: write # required to checkout the code from the repo and to perform release | ||
packages: write # required to publish to packages | ||
pull-requests: write | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
name: Package Build & Publish | ||
permissions: | ||
contents: read | ||
packages: write # allow GITHUB_TOKEN to publish packages | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: "20" | ||
- run: cd ./package && npm install | ||
- run: cd ./package && npm run build | ||
- uses: JS-DevTools/npm-publish@v3 | ||
with: | ||
package: './package/package.json' | ||
token: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
--- | ||
name: Semantic Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- release | ||
- beta | ||
paths: | ||
- 'package/**' | ||
|
||
permissions: | ||
id-token: write # required to use OIDC authentication | ||
contents: write # required to checkout the code from the repo and to perform release | ||
packages: write # required to publish to packages | ||
pull-requests: write | ||
|
||
jobs: | ||
check: | ||
name: GitHub Prerequisites Check | ||
runs-on: ubuntu-latest | ||
outputs: | ||
has_gh_secrets: ${{ steps.check-gh-key-secret.outputs.declared }} | ||
steps: | ||
- name: Check for GitHub Secret availability | ||
id: check-gh-key-secret | ||
shell: bash | ||
run: | | ||
if [[ ! -z "${{ secrets.GITHUB_TOKEN }}" ]]; then | ||
echo "All secrets are declared." | ||
echo "declared=true" >> $GITHUB_OUTPUT; | ||
else | ||
echo "GITHUB_TOKEN secret is missing." | ||
exit 1 | ||
fi | ||
check_version_number: | ||
name: Check version | ||
needs: [check] | ||
runs-on: ubuntu-latest | ||
if: | | ||
needs.check.outputs.has_gh_secrets | ||
&& github.actor != 'nektos/act' | ||
permissions: | ||
contents: write # to be able to publish a GitHub release | ||
issues: write # to be able to comment on released issues | ||
pull-requests: write # to be able to comment on released pull requests | ||
outputs: | ||
new_release_published: ${{ steps.semantic_dry.outputs.new_release_published }} | ||
new_release_version: ${{ steps.semantic_dry.outputs.new_release_version }} | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Get semantic release version | ||
uses: cycjimmy/semantic-release-action@v3 | ||
id: semantic_dry | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
dry_run: true | ||
branches: | | ||
[ | ||
"+([0-9])?(.{+([0-9]),x}).x", | ||
"release", | ||
{ | ||
"name": "beta", | ||
"prerelease": true | ||
} | ||
] | ||
extends: | | ||
[email protected] | ||
extra_plugins: | | ||
@semantic-release/[email protected] | ||
@semantic-release/[email protected] | ||
@semantic-release/[email protected] | ||
@semantic-release/[email protected] | ||
tag_version: | ||
name: Add semantic release | ||
needs: [check, check_version_number] | ||
if: | | ||
needs.check.outputs.has_gh_secrets | ||
&& needs.check_version_number.outputs.new_release_published | ||
&& github.actor != 'nektos/act' | ||
permissions: | ||
contents: write # to be able to publish a GitHub release | ||
issues: write # to be able to comment on released issues | ||
pull-requests: write # to be able to comment on released pull requests | ||
runs-on: ubuntu-latest | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
persist-credentials: false # make sure the release step uses its own credentials | ||
- name: Semantic Release | ||
uses: cycjimmy/semantic-release-action@v3 | ||
id: semantic | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
semantic_version: 19 | ||
branches: | | ||
[ | ||
"+([0-9])?(.{+([0-9]),x}).x", | ||
"release", | ||
{ | ||
"name": "beta", | ||
"prerelease": true | ||
} | ||
] | ||
extends: | | ||
[email protected] | ||
extra_plugins: | | ||
@semantic-release/[email protected] | ||
@semantic-release/[email protected] | ||
@semantic-release/[email protected] | ||
@semantic-release/[email protected] | ||
- name: Changelog version | ||
if: steps.semantic.outputs.new_release_published == 'true' | ||
run: | | ||
echo ${{ steps.semantic.outputs.new_release_version }} | ||
outputs: | ||
new_release: ${{ steps.semantic.outputs.new_release_published }} | ||
new_version: ${{ steps.semantic.outputs.new_release_version }} | ||
|
||
github-publish: | ||
name: GitHub Build & Publish - ${{ needs.tag_version.outputs.new_version }} | ||
needs: [tag_version] | ||
if: | | ||
needs.check.outputs.has_gh_secrets | ||
&& needs.tag_version.outputs.new_release | ||
uses: ./.github/workflows/build-and-publish.yaml | ||
with: | ||
release_tag: ${{ needs.tag_version.outputs.new_version }} | ||
dry_run: false | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
{ | ||
"tagFormat": "v${version}", | ||
"initialVersion": "0.1.0", | ||
"branches": [ | ||
"release", | ||
{ | ||
"name": "beta", | ||
"prerelease": true | ||
} | ||
], | ||
"ci": true, | ||
"debug": true, | ||
"plugins": [ | ||
[ | ||
"@semantic-release/commit-analyzer", | ||
{ | ||
"preset": "conventionalcommits", | ||
"releaseRules": [ | ||
{ | ||
"type": "revert", | ||
"release": "patch" | ||
}, | ||
{ | ||
"type": "docs", | ||
"release": "patch" | ||
}, | ||
{ | ||
"type": "style", | ||
"release": "patch" | ||
}, | ||
{ | ||
"type": "chore", | ||
"release": "patch" | ||
}, | ||
{ | ||
"type": "refactor", | ||
"release": "patch" | ||
}, | ||
{ | ||
"type": "test", | ||
"release": "patch" | ||
}, | ||
{ | ||
"type": "build", | ||
"release": "patch" | ||
}, | ||
{ | ||
"type": "ci", | ||
"release": "patch" | ||
}, | ||
{ | ||
"type": "improvement", | ||
"release": "minor" | ||
} | ||
], | ||
"parserOpts": { | ||
"noteKeywords": [ | ||
"BREAKING CHANGE", | ||
"BREAKING CHANGES" | ||
] | ||
} | ||
} | ||
], | ||
[ | ||
"@semantic-release/release-notes-generator", | ||
{ | ||
"preset": "conventionalcommits", | ||
"presetConfig": { | ||
"types": [ | ||
{ | ||
"type": "feat", | ||
"section": "Features" | ||
}, | ||
{ | ||
"type": "fix", | ||
"section": "Bug Fixes" | ||
}, | ||
{ | ||
"type": "perf", | ||
"section": "Performance Improvements" | ||
}, | ||
{ | ||
"type": "revert", | ||
"section": "Reverts" | ||
}, | ||
{ | ||
"type": "docs", | ||
"section": "Documentation", | ||
"hidden": false | ||
}, | ||
{ | ||
"type": "style", | ||
"section": "Styles", | ||
"hidden": false | ||
}, | ||
{ | ||
"type": "chore", | ||
"section": "Miscellaneous Chores", | ||
"hidden": false | ||
}, | ||
{ | ||
"type": "refactor", | ||
"section": "Code Refactors", | ||
"hidden": false | ||
}, | ||
{ | ||
"type": "test", | ||
"section": "Tests", | ||
"hidden": false | ||
}, | ||
{ | ||
"type": "build", | ||
"section": "Build System", | ||
"hidden": false | ||
}, | ||
{ | ||
"type": "ci", | ||
"section": "CI/CD", | ||
"hidden": false | ||
}, | ||
{ | ||
"type": "improvement", | ||
"section": "Improvements", | ||
"hidden": false | ||
} | ||
] | ||
} | ||
} | ||
], | ||
[ | ||
"@semantic-release/npm", | ||
{ | ||
"npmPublish": false, | ||
"pkgRoot": "./package" | ||
} | ||
], | ||
"@semantic-release/github", | ||
[ | ||
"@semantic-release/changelog", | ||
{ | ||
"changelogFile": "package/changelogs/CHANGELOG.md" | ||
} | ||
], | ||
[ | ||
"@semantic-release/exec", | ||
{ | ||
"prepareCmd": "mv package/changelogs/CHANGELOG.md package/changelogs/CHANGELOG-${nextRelease.version}.md;" | ||
} | ||
], | ||
[ | ||
"@semantic-release/git", | ||
{ | ||
"assets": [ | ||
"package/package.json", | ||
"package/changelogs/**", | ||
"package/dist/**" | ||
], | ||
"message": "chore(release): ${nextRelease.version} [skip ci]" | ||
} | ||
] | ||
] | ||
} |