-
Notifications
You must be signed in to change notification settings - Fork 27
64 lines (57 loc) · 2.62 KB
/
arc-themes-base-to-new-tag.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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: "16"
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 }}