Tag New Arc Theme Release #49
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: Tag New Arc Theme Release | |
on: | |
workflow_dispatch: | |
inputs: | |
target_release_tag: | |
description: "Base tag (eg, 1.18 if arc-themes-release-version-1.18 -> arc-themes-release-version-1.19)" | |
required: true | |
new_release_tag: | |
description: "New tag (eg, 1.19 if arc-themes-release-version-1.18 -> arc-themes-release-version-1.19)" | |
required: true | |
jobs: | |
validate_tags: | |
name: Validate release numbers | |
runs-on: ubuntu-latest | |
# ensure new and target release tags match regex: | |
# {numbers}.{numbers} requirement per product | |
steps: | |
- name: Check target release tag name | |
id: check-target-tag | |
run: | | |
if [[ ${{ github.event.inputs.target_release_tag }} =~ ^([0-9]+)\.([0-9]+)(\.[0-9]+)?$ ]]; then | |
echo ::set-output name=match::true | |
fi | |
- name: Check new release tag name | |
id: check-new-tag | |
run: | | |
if [[ ${{ github.event.inputs.new_release_tag }} =~ ^([0-9]+)\.([0-9]+)(\.[0-9]+)?$ ]]; then | |
echo ::set-output name=match::true | |
fi | |
- name: Validate release tag numbers | |
id: validate-release-tag-numbers | |
if: steps.check-target-tag.outputs.match != 'true' && steps.check-new-tag.outputs.match != 'true' | |
# fail if one check fails | |
# passes by default | |
# exit 0 is pass | |
run: exit 1 | |
retag: | |
name: Tag base tag to new tag | |
runs-on: ubuntu-latest | |
# previous and any future jobs need this needs property | |
needs: validate_tags | |
env: | |
TARGET_RELEASE_TAG: arc-themes-release-version-${{ github.event.inputs.target_release_tag }} | |
NEW_RELEASE_TAG: arc-themes-release-version-${{ github.event.inputs.new_release_tag }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Setup Node and NPM | |
uses: actions/setup-node@v3 | |
with: | |
node-version-file: .nvmrc | |
registry-url: "https://npm.pkg.github.com" | |
# See confluence pages https://arcpublishing.atlassian.net/wiki/spaces/TI/pages/2983788608/How+To+Do+Product-Facing+Tag+Release and https://arcpublishing.atlassian.net/wiki/spaces/TI/pages/3013541978/Github+Actions+for+NodeJS+Standards+Best+Practices for documentation | |
- name: Get version of target tag and point the new tag to that version | |
run: npx lerna exec --stream --no-bail --concurrency 1 -- 'PKG_VERSION=$(npm view ${LERNA_PACKAGE_NAME}@${{ env.TARGET_RELEASE_TAG }} version); [ -n "$PKG_VERSION" ] && (npm dist-tag add ${LERNA_PACKAGE_NAME}@${PKG_VERSION} ${{ env.NEW_RELEASE_TAG }}) || exit 0' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |