Skip to content

More testin in lerna check step #83

More testin in lerna check step

More testin in lerna check step #83

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: Lerna checks
run: |
npm run lint:scss
npx lerna --version
- 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
# Get the latest commits and declare latest commit into var
git fetch
export LATEST_HASH=$(git rev-list --tags --max-count=1)
# THIS IS NOT TAGGING TO THE ACTUAL RELEASE BRANCH?? ^
# See notice here (automation): https://github.com/penske-media-corp/pmc-larva/commit/35ceb11b3f561ba35a0d81da313316930d644c11
# vs lack of notice when doing it manually: https://github.com/penske-media-corp/pmc-larva/commit/b3385249708181dc1f48b4530bd3c10a387c3778
#
# REMEMBER TO UN-COMMENT THE ON-PUSH TRIGGER!
#
echo '🤩🤩 ➡️ Finished lerna publish'
git status
git add -A
# git add .
echo '🤩🤩 ➡️ Added working changes after lerna publish'
git commit -m 'Update package versioning'
echo '🤩🤩 ➡️ Committed package versioning update'
# Get latest commit from release tag and add it to release branch.
git status
echo '🤩🤩 ➡️ Finished committing'
git push
echo '🤩🤩 ➡️ Finish pushing first commit'
git cherry-pick $LATEST_HASH --keep-redundant-commits
echo '🤩🤩 ➡️ Cherry-picked $LATEST_HASH'
git --no-pager log -1 --pretty=format:"%h - %an, %ar : %s"
echo '🤩🤩 ➡️ Did git log after cherry-pick'
# git cherry-pick --continue
# git cherry-pick --skip
# echo '🤩🤩 ➡️ Finished cherry picking'
git diff
echo '🤩🤩 ➡️ Diffed after cherry-pick'
# git add -A
# echo '🤩🤩 ➡️ Added working changes post-cherry-pick'
# git commit -m "Cherry pick last commit from lerna"
# git commit --allow-empty -m "Cherry pick last commit from lerna"
# echo '🤩🤩 ➡️ Commit the cherry pick'
git push
echo '🤩🤩 ➡️ Push the cherry pick'
git status
echo '🤩🤩 ➡️ Status after the cherry pick push'
git diff
echo '🤩🤩 ➡️ Diff after the cherry pick push'
env:
# testing a fake secret to see if anything changes.
TEST_VAR: ${{ secrets.FAKE_FAKE }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
- name: Create Pull Request
uses: peter-evans/[email protected]
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.