push CRWA package version changes (#8865) #209
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 Canary | |
on: | |
push: | |
branches: [main, next] | |
# We don't want this to run when we publish a release. | |
tags-ignore: ['v**'] | |
# No need to run on docs-only changes | |
paths-ignore: ['docs/**'] | |
# Cancel in-progress runs of this workflow. | |
# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow. | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
publish-canary: | |
name: π¦ Publish Canary | |
if: github.repository == 'redwoodjs/redwood' | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.get-version.outputs.value }} | |
steps: | |
- uses: actions/checkout@v3 | |
# `fetch-depth`βnumber of commits to fetch. `0` fetches all history for all branches and tags. | |
# This is required because lerna uses tags to determine the version. | |
with: | |
fetch-depth: 0 | |
- name: β¬’ Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: π Set up yarn cache | |
uses: ./.github/actions/set-up-yarn-cache | |
- name: π Yarn install | |
run: yarn install --inline-builds | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: β Check constraints, dependencies, and package.json's | |
uses: ./tasks/check | |
- name: π Build | |
run: yarn build | |
- name: π Lint | |
run: yarn lint | |
- name: π§ͺ Test | |
run: yarn test | |
- name: π’ Publish | |
run: | | |
echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > .npmrc | |
TAG='canary' && [[ "$GITHUB_REF_NAME" = 'next' ]] && TAG='next' | |
echo "Publishing $TAG" | |
args=() | |
if [[ "$GITHUB_REF_NAME" = 'main' ]]; then | |
args+=(premajor) | |
fi | |
args+=( | |
--include-merged-tags | |
--canary | |
--exact | |
--preid "$TAG" | |
--dist-tag "$TAG" | |
--force-publish | |
--loglevel verbose | |
--no-git-reset | |
) | |
# `echo 'n'` to answer "no" to the "Are you sure you want to publish | |
# these packages?" prompt. | |
# `|&` to pipe both stdout and stderr to grep. Mostly do this keep | |
# the github action output clean. | |
echo 'n' \ | |
| yarn lerna publish "${args[@]}" \ | |
|& grep '\-canary\.' \ | |
| tail -n 1 \ | |
| sed 's/.*=> //' \ | |
| sed 's/\+.*//' \ | |
> canary_version | |
echo "Will publish:" | |
echo "Canary version $(cat canary_version)" | |
cat packages/create-redwood-app/templates/js/package.json \ | |
| sed "s/\"@redwoodjs\/\(.*\)\": \".*\"/\"@redwoodjs\/\1\": \"$(cat canary_version)\"/" \ | |
> packages/create-redwood-app/templates/js/package.json | |
cat packages/create-redwood-app/templates/js/api/package.json \ | |
| sed "s/\"@redwoodjs\/\(.*\)\": \".*\"/\"@redwoodjs\/\1\": \"$(cat canary_version)\"/" \ | |
> packages/create-redwood-app/templates/js/api/package.json | |
cat packages/create-redwood-app/templates/js/web/package.json \ | |
| sed "s/\"@redwoodjs\/\(.*\)\": \".*\"/\"@redwoodjs\/\1\": \"$(cat canary_version)\"/" \ | |
> packages/create-redwood-app/templates/js/web/package.json | |
cat packages/create-redwood-app/templates/ts/package.json \ | |
| sed "s/\"@redwoodjs\/\(.*\)\": \".*\"/\"@redwoodjs\/\1\": \"$(cat canary_version)\"/" \ | |
> packages/create-redwood-app/templates/ts/package.json | |
cat packages/create-redwood-app/templates/ts/api/package.json \ | |
| sed "s/\"@redwoodjs\/\(.*\)\": \".*\"/\"@redwoodjs\/\1\": \"$(cat canary_version)\"/" \ | |
> packages/create-redwood-app/templates/ts/api/package.json | |
cat packages/create-redwood-app/templates/ts/web/package.json \ | |
| sed "s/\"@redwoodjs\/\(.*\)\": \".*\"/\"@redwoodjs\/\1\": \"$(cat canary_version)\"/" \ | |
> packages/create-redwood-app/templates/ts/web/package.json | |
echo "" | |
echo "Updated ts web package.json:" | |
cat packages/create-redwood-app/templates/ts/web/package.json | |
echo "" | |
git commit -am "Update create-redwood-app templates to use canary packages" | |
git log --oneline -n 10 | |
git push | |
args+=(--yes) | |
yarn lerna publish "${args[@]}" | |
env: | |
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
- name: π· Get version | |
id: get-version | |
uses: sergeysova/jq-action@v2.3.0 | |
with: | |
cmd: 'jq .version packages/core/package.json -r' | |
message-slack: | |
name: π¬ Message Slack | |
needs: publish-canary | |
if: ${{ !cancelled() }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: π¬ Message Slack | |
uses: ./.github/actions/message_slack_publishing | |
with: | |
title: "π¦ Canary Packages" | |
status: ${{ needs.publish-canary.result }} | |
version: ${{ needs.publish-canary.outputs.version }} | |
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL_PACKAGE_PUBLISHING }} |