THEMES-1908: republishing all blocks via readme changes. (#2114) #551
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: Publish to themes target tag based off of themes branch name | |
on: | |
push: | |
branches: | |
# only run on branch names that match: | |
# arc-themes-release-version-{numbers}.{numbers} per product | |
- arc-themes-release-version-[0-9]+\.[0-9]+ | |
# only run on changes to these files | |
paths: | |
- "**.js" | |
- "**.jsx" | |
- "**.scss" | |
- "**/intl.json" | |
- "**/README.md" | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
env: | |
SYNCED_RELEASE_TAG: ${{ github.ref_name }} # targets branch name ref_name | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# pulls all tags (needed for lerna / semantic release to correctly version) | |
- name: Pull tags to give lerna access to git info | |
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18" | |
registry-url: "https://npm.pkg.github.com" | |
- name: Cache Node Modules | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
path: node_modules | |
key: node-modules-${{ hashFiles('package-lock.json') }} | |
- name: Clean install (CI) dependencies if lockfile (above) changed | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: npm ci | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
#- name: Run all tests | |
# run: npm run test | |
- name: Publish to target tag based off of branch name | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "$GITHUB_ACTOR" | |
npx lerna publish --dist-tag ${{ env.SYNCED_RELEASE_TAG }} --canary --preid ${{ env.SYNCED_RELEASE_TAG }} -y | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
tag_canary_if_1x: | |
runs-on: ubuntu-latest | |
# has to run publish job first successfully | |
needs: publish | |
# checks for presence of "-1." in branch name already matching criteria arc-themes-release-version-[0-9]+\.[0-9]+ | |
# contains('Hello', 'ello') -> returns true docs https://docs.github.com/en/actions/learn-github-actions/expressions#contains | |
if: contains(github.ref_name, '-1.') | |
env: | |
SYNCED_RELEASE_TAG: ${{ github.ref_name }} # targets branch name ref_name | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
- name: Setup Node and NPM | |
uses: actions/setup-node@v1 | |
with: | |
node-version: "12" | |
registry-url: "https://npm.pkg.github.com" | |
- name: Tag 1.x release with canary | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "$GITHUB_ACTOR" | |
npx lerna exec --stream --no-bail --concurrency 1 -- 'PKG_VERSION=$(npm view ${LERNA_PACKAGE_NAME}@${{ env.SYNCED_RELEASE_TAG }} version); [ -n "$PKG_VERSION" ] && (npm dist-tag add ${LERNA_PACKAGE_NAME}@${PKG_VERSION} canary) || exit 0' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |