-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow to release from own repo (#34)
Closes #2 Signed-off-by: Jon Koops <[email protected]>
- Loading branch information
Showing
3 changed files
with
145 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,18 @@ | ||
name: Release Nightly | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
||
release-nightly: | ||
name: Nightly release | ||
if: github.event_name != 'schedule' || github.repository == 'keycloak/keycloak-js' | ||
uses: ./.github/workflows/x-release.yml | ||
with: | ||
gh-org: keycloak | ||
branch: ${{ github.ref_name }} | ||
tag: nightly | ||
nightly: true |
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,21 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: Release version | ||
required: true | ||
|
||
jobs: | ||
|
||
release: | ||
name: Release | ||
uses: ./.github/workflows/x-release.yml | ||
with: | ||
gh-org: keycloak | ||
branch: ${{ github.ref_name }} | ||
tag: ${{ inputs.version }} | ||
nightly: false | ||
secrets: | ||
NPM_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,106 @@ | ||
name: X Release | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
gh-org: | ||
required: true | ||
type: string | ||
branch: | ||
required: true | ||
type: string | ||
tag: | ||
required: true | ||
type: string | ||
nightly: | ||
required: true | ||
type: boolean | ||
secrets: | ||
NPM_TOKEN: | ||
required: false | ||
|
||
concurrency: rel-${{ github.ref }} | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
|
||
release-impl: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.branch }} | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 22 | ||
check-latest: true | ||
registry-url: https://registry.npmjs.org | ||
|
||
- name: Create version commit | ||
if: ${{ !inputs.nightly }} | ||
run: | | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --global user.name "github-actions[bot]" | ||
npm version ${{ inputs.tag }} -m "Set version to ${{ inputs.tag }}" | ||
- name: Tag commit | ||
run: git tag ${{ inputs.tag }} | ||
|
||
- name: Push changes | ||
run: git push --force origin refs/tags/${{ inputs.tag }} | ||
|
||
- name: Create a github release if does not exists | ||
id: create-release-if-not-exists | ||
run: | | ||
if ( gh release view ${{ inputs.tag }} --repo ${{ inputs.gh-org }}/keycloak-js &> /dev/null ); then | ||
echo "Release ${{ inputs.tag }} already exists" | ||
else | ||
gh release create ${{ inputs.tag }} --repo ${{ inputs.gh-org }}/keycloak-js --title ${{ inputs.tag }} --draft ${{ inputs.nightly && '--prerelease' || '' }} | ||
fi | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create package tarball | ||
run: | | ||
npm pack | ||
mv -T *.tgz keycloak-js.tgz | ||
- name: Create guides zip | ||
run: | | ||
npm ci | ||
npm run guides | ||
- name: Upload to GitHub Releases | ||
run: | | ||
for i in `gh release view ${{ inputs.tag }} --json assets --jq '.assets[].name'`; do | ||
test -f $i || gh release delete-asset ${{ inputs.tag }} $i -y | ||
done | ||
gh release upload ${{ inputs.tag }} keycloak-js.tgz "guides/target/keycloak-js-guides.zip" --clobber | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Publish release | ||
run: gh release edit ${{ inputs.tag }} --repo ${{ inputs.gh-org }}/keycloak-js --draft=false | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Show Output Github | ||
run: | | ||
echo "https://github.com/${{ inputs.gh-org }}/keycloak-js/tree/${{ inputs.tag }} " >> $GITHUB_STEP_SUMMARY | ||
echo "https://github.com/${{ inputs.gh-org }}/keycloak-js/releases/tag/${{ inputs.tag }} " >> $GITHUB_STEP_SUMMARY | ||
- name: Publish to NPM | ||
if: ${{ !inputs.nightly }} | ||
run: npm publish keycloak-js.tgz --access public --ignore-scripts ${{ inputs.gh-org != 'keycloak' && ' --dry-run' || '' }} | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Show Output NPM | ||
if: ${{ !inputs.nightly && inputs.gh-org == 'keycloak' }} | ||
run: echo "https://www.npmjs.com/package/keycloak-js/v/${{ inputs.tag }} " >> $GITHUB_STEP_SUMMARY |