-
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.
chore(ci): add GitHub Action NPM publish prompt version workflow (#172)
- Loading branch information
1 parent
5e99b03
commit 2d21378
Showing
4 changed files
with
122 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,110 @@ | ||
name: 🏷️ Publish NPM (version prompt) | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Fixed Version' | ||
required: true | ||
type: string | ||
tag: | ||
type: choice | ||
description: Tag | ||
options: | ||
- latest | ||
- beta | ||
|
||
permissions: | ||
contents: write | ||
id-token: write | ||
|
||
jobs: | ||
deploy-npm-beta: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
steps: | ||
- name: Retrieve current Date Time in EST | ||
shell: bash | ||
run: echo "START_TIME=$(TZ=":America/New_York" date -R|sed 's/.....$//')" >> $GITHUB_ENV | ||
|
||
- name: Current datetime - ${{ env.START_TIME }} | ||
run: echo ${{ env.START_TIME }} | ||
|
||
- name: Clone repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 3 | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- if: ${{ github.event.pull_request.merged != true && contains('["ghiscoding"]', github.actor) != true }} | ||
name: Ensure current actor is allowed to run the workflow | ||
run: | | ||
echo "Error: Your GitHub username (${{ github.actor }}) is not on the allowed list of admins for this workflow" | ||
exit 1 | ||
- name: Set NodeJS | ||
uses: actions/setup-node@v4 | ||
with: | ||
registry-url: 'https://registry.npmjs.org/' | ||
node-version: 20 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
run_install: false | ||
|
||
- name: Get pnpm store directory | ||
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
|
||
- name: Setup pnpm cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ env.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
- name: Run pnpm install dependencies | ||
run: pnpm install | ||
|
||
- name: Run all workspace TSC builds | ||
run: pnpm build:full | ||
|
||
- name: Lerna Version (latest) 🏷️ | ||
if: ${{ contains(inputs.tag, 'latest') }} | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: | | ||
git config --global user.name "${{ github.actor }}" | ||
git config --global user.email "${{ github.actor }}@users.noreply.github.com" | ||
pnpm whoami | ||
pnpm run ci:version ${{ inputs.version }} | ||
- name: Lerna Version (beta) 🏷️ | ||
if: ${{ contains(inputs.tag, 'beta') }} | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: | | ||
git config --global user.name "${{ github.actor }}" | ||
git config --global user.email "${{ github.actor }}@users.noreply.github.com" | ||
pnpm whoami | ||
pnpm run lerna -- version prerelease --conventional-commits --conventional-prerelease --preid beta --force-publish --yes | ||
- name: OTP | ||
uses: step-security/wait-for-secrets@v1 | ||
id: wait-for-secrets | ||
with: | ||
secrets: | | ||
OTP: | ||
name: 'OTP to publish package' | ||
description: 'OTP from authenticator app' | ||
- name: Lerna Publish 📦 | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: | | ||
pnpm run ci:publish --otp ${{ steps.wait-for-secrets.outputs.OTP }} |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.