Publish v1.x #11
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
name: Publish v1.x | |
on: | |
workflow_dispatch: | |
inputs: | |
releaseType: | |
type: choice | |
description: Release Type | |
options: | |
- release | |
- prerelease | |
- graduate | |
jobs: | |
authorize: | |
name: Authorize | |
runs-on: ubuntu-latest | |
steps: | |
- name: ${{ github.actor }} permission check to do a release | |
uses: 'lannonbr/[email protected]' | |
with: | |
permission: 'write' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: [authorize] | |
permissions: | |
id-token: write | |
contents: write | |
env: | |
RELEASE_TYPE: ${{ github.event.inputs.releaseType }} | |
strategy: | |
matrix: | |
node-version: [16.x] | |
steps: | |
- name: Check out git repository | |
uses: actions/checkout@v3 | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} | |
- name: enable corepack | |
run: corepack enable | |
- name: set node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 'lts/*' | |
cache: 'yarn' | |
- name: Install project dependencies | |
run: | | |
yarn install --frozen-lockfile | |
- name: Build package | |
run: | | |
yarn build | |
- name: Test package | |
run: | | |
yarn test | |
- name: Configure Git User | |
run: | | |
git config --global user.name amplitude-sdk-bot | |
git config --global user.email [email protected] | |
- name: Configure NPM User | |
run: | | |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | |
npm whoami | |
- name: Conventional Changelog Action | |
id: changelog | |
uses: TriPSs/[email protected] | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
version-file: './package.json,./package-lock.json' | |
- name: create release | |
uses: actions/create-release@v1 | |
if: ${{ steps.changelog.outputs.skipped == 'false' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.changelog.outputs.tag }} | |
release_name: ${{ steps.changelog.outputs.tag }} | |
body: ${{ steps.changelog.outputs.clean_changelog }} | |
- name: Publish Release to NPM | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |