-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): move canary publishing script to file (#8877)
Co-authored-by: Tobbe Lundberg <[email protected]>
- Loading branch information
Showing
2 changed files
with
70 additions
and
68 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/bin/bash | ||
# | ||
# Used in the publish-canary.yml GitHub Action workflow. | ||
|
||
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. | ||
# At the end we use awk to increase the commit count by 1, because we'll commit | ||
# updated package.jsons in the next step, which will increase increase the | ||
# final number that lerna will use when publishing the canary packages. | ||
echo 'n' \ | ||
| yarn lerna publish "${args[@]}" \ | ||
|& grep '\-canary\.' \ | ||
| tail -n 1 \ | ||
| sed 's/.*=> //' \ | ||
| sed 's/\+.*//' \ | ||
| awk -F. '{ $NF = $NF + 1 } 1' OFS=. \ | ||
> canary_version | ||
|
||
sed "s/\"@redwoodjs\/\(.*\)\": \".*\"/\"@redwoodjs\/\1\": \"$(cat canary_version)\"/" \ | ||
packages/create-redwood-app/templates/js/package.json > tmpfile \ | ||
&& mv tmpfile packages/create-redwood-app/templates/js/package.json | ||
sed "s/\"@redwoodjs\/\(.*\)\": \".*\"/\"@redwoodjs\/\1\": \"$(cat canary_version)\"/" \ | ||
packages/create-redwood-app/templates/js/api/package.json > tmpfile \ | ||
&& mv tmpfile packages/create-redwood-app/templates/js/api/package.json | ||
sed "s/\"@redwoodjs\/\(.*\)\": \".*\"/\"@redwoodjs\/\1\": \"$(cat canary_version)\"/" \ | ||
packages/create-redwood-app/templates/js/web/package.json > tmpfile \ | ||
&& mv tmpfile packages/create-redwood-app/templates/js/web/package.json | ||
|
||
sed "s/\"@redwoodjs\/\(.*\)\": \".*\"/\"@redwoodjs\/\1\": \"$(cat canary_version)\"/" \ | ||
packages/create-redwood-app/templates/ts/package.json > tmpfile \ | ||
&& mv tmpfile packages/create-redwood-app/templates/ts/package.json | ||
sed "s/\"@redwoodjs\/\(.*\)\": \".*\"/\"@redwoodjs\/\1\": \"$(cat canary_version)\"/" \ | ||
packages/create-redwood-app/templates/ts/api/package.json > tmpfile \ | ||
&& mv tmpfile packages/create-redwood-app/templates/ts/api/package.json | ||
sed "s/\"@redwoodjs\/\(.*\)\": \".*\"/\"@redwoodjs\/\1\": \"$(cat canary_version)\"/" \ | ||
packages/create-redwood-app/templates/ts/web/package.json > tmpfile \ | ||
&& mv tmpfile packages/create-redwood-app/templates/ts/web/package.json | ||
|
||
git config user.name "GitHub Actions" | ||
git config user.email "<>" | ||
|
||
git commit -am "Update create-redwood-app templates to use canary packages" | ||
|
||
args+=(--yes) | ||
yarn lerna publish "${args[@]}" |
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