Prerelease feature branch #9
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: Prerelease feature branch | |
on: | |
workflow_dispatch: | |
inputs: | |
releaseType: | |
type: choice | |
description: Select dry-run for testing before real prerelease | |
required: true | |
options: | |
- dry-run | |
- prerelease | |
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 | |
strategy: | |
matrix: | |
node-version: [18.15.x] | |
steps: | |
- name: Get branch name | |
id: branch-name | |
uses: tj-actions/branch-name@v7 | |
- name: Check out git repository | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ steps.branch-name.outputs.ref_branch }} | |
fetch-depth: 0 | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} | |
- name: Setup Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install project dependencies | |
run: | | |
yarn install --frozen-lockfile | |
- name: Build all packages | |
run: | | |
yarn build | |
- name: Test all packages | |
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 | |
# Converted to all lowercase and stripped of non-letter characters | |
- name: Transform feature branch name | |
run: | | |
echo "PREID=$(echo '${{ steps.branch-name.outputs.current_branch }}' | tr -cd '[:lower:]')" >> $GITHUB_ENV | |
- name: Conventional Changelog Action | |
id: changelog | |
uses: TriPSs/conventional-changelog-action@v5 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
version-file: './package.json,./package-lock.json' | |
pre-release: 'true' | |
pre-release-identifier: ${{ env.PREID }} | |
# Use 'from git' option if `lerna version` has already been run | |
- name: Publish Release to NPM | |
if: ${{ github.event.inputs.releaseType == 'prerelease' }} | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |