Release #146
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: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
draft: | |
description: 'Draft' | |
required: true | |
default: false | |
type: boolean | |
update_all: | |
description: 'Force update all packages' | |
required: true | |
default: false | |
type: boolean | |
version-increment-type: | |
description: 'Which part of the version to increment:' | |
required: true | |
type: choice | |
options: | |
- major | |
- minor | |
- patch | |
default: 'patch' | |
permissions: | |
contents: write | |
id-token: write | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x] | |
env: | |
GITHUB_TOKEN: ${{ secrets.AUTOMATION_USER_TOKEN }} | |
steps: | |
# Check out the repo with credentials that can bypass branch protection, and fetch git history instead of just latest commit | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.AUTOMATION_USER_TOKEN }} | |
fetch-depth: 0 | |
- name: Set Secrets | |
uses: DevCycleHQ/aws-secrets-action@main | |
with: | |
secrets_map: '{"NODE_AUTH_TOKEN":"DEVCYCLE_GITHUB_JS-SDKS_NPM_TOKEN"}' | |
aws_account_id: '134377926370' | |
- name: Configure git | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "DevCycle Automation" | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
registry-url: 'https://registry.npmjs.org' | |
cache: 'yarn' | |
- name: Validate npm config and auth | |
run: | | |
npm config list | |
npm whoami | |
- run: yarn --immutable | |
# Only one of the following two steps will run, depending on whether the `update_all` input is set | |
- name: Increment affected package versions with lerna | |
run: | | |
./scripts/lerna-version-ci.sh --version-increment-type "${{ inputs.version-increment-type }}" | |
if: inputs.update_all != true | |
- name: Increment all package versions with lerna | |
run: | | |
./scripts/lerna-version-ci.sh --all-packages --version-increment-type="${{ inputs.version-increment-type }}" | |
if: inputs.update_all == true | |
- name: Push version changes and tags | |
run: | | |
git push origin HEAD:main --follow-tags | |
if: inputs.draft != true && github.ref == 'refs/heads/main' | |
- name: Push to npm | |
run: | | |
yarn npm-publish | |
if: inputs.draft != true | |
- name: Push to npm (dry run) | |
run: | | |
yarn npm-publish --dry-run | |
if: inputs.draft == true | |
- name: Build UMD bundles | |
run: | | |
yarn nx build:cdn js | |
- name: Extract SDK version | |
run: | | |
echo "SDK_VERSION=$(cat sdk/js/package.json | jq -r '.version')" >> $GITHUB_ENV | |
- name: Upload CDN Release | |
run: | | |
SDK_VERSION="$(cat sdk/js/package.json | jq -r ".version")" | |
aws s3 sync dist/sdk/cdn/js s3://js.devcycle.com/ --include "devcycle.min.js*" --acl public-read | |
aws s3 sync dist/sdk/cdn/js s3://js.devcycle.com/latest/ --include "devcycle.min.js*" --acl public-read | |
aws s3 sync dist/sdk/cdn/js s3://js.devcycle.com/${SDK_VERSION}/ --include "devcycle.min.js*" --acl public-read | |
if: inputs.draft != true && github.ref == 'refs/heads/main' | |
env: | |
SDK_VERSION: ${{ env.SDK_VERSION }} | |