Publish #3
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
# Run locally with act: | |
# | |
# act workflow_dispatch \ | |
# --input command=<test|publish> \ | |
# --input version=<version> \ | |
# --workflows ./.github/workflows/release.yaml \ | |
# --platform fusionauth-standard=[repo]/gha-runner-fusionauth-standard:latest \ | |
# --env-file <(aws configure export-credentials --profile [aws-profile] --format env) | |
name: Publish | |
on: | |
workflow_dispatch: | |
inputs: | |
command: | |
required: true | |
type: choice | |
options: | |
- test | |
- publish | |
default: test | |
version: | |
required: true | |
type: string | |
permissions: | |
contents: write | |
jobs: | |
publish: | |
runs-on: fusionauth-standard | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: configure git | |
shell: bash | |
run: | | |
git config --global user.name "FusionAuth Automation" | |
git config --global user.email "[email protected]" | |
- name: set aws credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.ACTIONS_AWS_ROLE_ARN }} | |
role-session-name: aws-auth-action | |
aws-region: us-west-2 | |
- name: get secret | |
run: | | |
while IFS=$'\t' read -r key value; do | |
echo "::add-mask::${value}" | |
echo "${key}=${value}" >> $GITHUB_ENV | |
done < <(aws secretsmanager get-secret-value \ | |
--region us-west-2 \ | |
--secret-id platform/npmjs \ | |
--query SecretString \ | |
--output text | \ | |
jq -r 'to_entries[] | [.key, .value] | @tsv') | |
- name: create npmrc | |
run: | | |
echo "color=false" > ~/.npmrc | |
echo "//registry.npmjs.org/:_authToken=${{ env.API_KEY }}" >> ~/.npmrc | |
chmod 600 ~/.npmrc | |
- name: set version | |
run: npm version ${{ inputs.version }} | |
- name: install dependencies | |
run: npm install | |
- name: build the package | |
run: npm run build | |
- name: test publish to npmjs | |
if: inputs.command == 'test' | |
run: npm publish --dry-run | |
- name: publish to npmjs (only on main branch) | |
if: inputs.command == 'publish' && github.ref == 'refs/heads/main' | |
run: npm publish | |
- name: commit version changes (only on main branch) | |
if: inputs.command == 'publish' && github.ref == 'refs/heads/main' | |
run: | | |
git commit -am "publish v${{ inputs.version }}" | |
git push origin main --tags |