Skip to content

Re-enable action so it can be tested with what will be 1.47.0 #70

Re-enable action so it can be tested with what will be 1.47.0

Re-enable action so it can be tested with what will be 1.47.0 #70

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: Release to npm
# -- steps for larva release, for reference
# this action would be triggered by: a button in the Actions tab
# start at the master branch
# checkout a release branch from master,
# increment the name (assume minor releases most of the time) by reading lerna json file
# run git checkout
# assume changelog has been updated
# run npx lerna publish
# asks if minor/major release, user has to manually type. probably https://github.com/lerna/lerna/tree/main/commands/version#options
# try running npx lerna publish minor --yes
# create a PR to merge release branch to master
# at least one human approval required (nice to have: auto ping #larva channel asking for PR approval)
# pipelines have to pass
# manual merge required (nice to have: have a machine user w/ token in the allowlist that can bypass)
# tag latest release on repo
# Controls when the workflow will run
# Allows you to run this workflow manually from the Actions tab
# docs: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
# https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
on:
# For action testing! Will need to update this when merged to main for the button to trigger action.
push:
# UN-COMMENT THESE OUT NEXT TIME
branches:
- feature/automated-releases
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
deploy-release:
name: Create and Deploy NPM Release
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout master branch
uses: actions/checkout@v3
with:
ref: 'master'
fetch-depth: '0'
- name: Checkout release branch
run: |
git fetch --depth=500 origin +refs/tags/*:refs/tags/*
# Get latest release tag name
export VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))
# Parsing the latest release tag name into an array
arrIN=(${VERSION//./ })
# Bump minor version by 1
export MINOR=$((arrIN[1]+1))
# prefix the branch with test-release for testing purposes.
export BRANCH_NAME="release/1.${MINOR}.0"
# export BRANCH_NAME="release/1.${MINOR}.0"
git checkout -b $BRANCH_NAME
git push --set-upstream origin $BRANCH_NAME
# Save the current branch name into an env variable.
echo "GH_BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
# Save the minor version number into an env variable.
echo "GH_MINOR=$MINOR" >> $GITHUB_ENV
- name: Use Node 14
uses: actions/setup-node@v3
with:
node-version: '14'
registry-url: 'https://registry.npmjs.org'
- name: Publish to npm
# https://dev.to/astagi/publish-to-npm-using-github-actions-23fn
# Check dist.dev NPM user in LastPass?
run: |
git config user.name pmc-machine-user
git config user.email "<>"
# Canary release for testing purposes. --prefix release with another-test
# npx lerna publish --canary --preid test-v3 --yes --tag-version-prefix='test-v' --no-git-reset
npx lerna publish minor --yes --no-git-reset
#
# REMEMBER TO UN-COMMENT THE ON-PUSH TRIGGER!
#
git status
git add -A
git commit -m 'Update package versioning'
git push
git status
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4.2.3
with:
# token: ${{ github.token }}
branch: ${{ env.GH_BRANCH_NAME }}
base: master
title: Release v1.${{ env.GH_MINOR }}.0
# body: probably autofills the PR template that already exists for larva?
# Engineer will then have to go into CHANGELOG.md to update the changelog
# NEXT STEPS: Clean up, push up to main branch, test that the workflow trigger will work.