forked from faker-js/faker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
63 additions
and
0 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,63 @@ | ||
name: Publish Release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
push: | ||
branches: | ||
- next | ||
|
||
permissions: | ||
contents: write # to push the release branch | ||
|
||
jobs: | ||
publish: | ||
name: Publish Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
|
||
- name: Set node version to 20 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: 'pnpm' | ||
|
||
- name: Prepare | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Gather release info | ||
run: | | ||
RELEASE_VERSION=$(jq -r '.version' package.json) | ||
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV | ||
RELEASE_MAJOR=$(jq -r '.version | split(".")[0]' package.json) | ||
echo "RELEASE_MAJOR=$RELEASE_MAJOR" >> $GITHUB_ENV | ||
DIST_TAG=$(jq -r '.version | if split("-")[1] == null then "latest" else "next" end' package.json) | ||
echo "DIST_TAG=$DIST_TAG" >> $GITHUB_ENV | ||
- name: Prepare README | ||
run: | | ||
sed -i '/.*You are reading the docs for the .*/d' README.md | ||
cat README.md | ||
- name: Set publishing config | ||
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NPM_AUTH_TOKEN}" | ||
#env: | ||
# NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | ||
|
||
- name: Publish | ||
run: | | ||
PACKAGE_DIST_TAG=$(node -e "console.log(/^\d+\.\d+\.\d+(\-(\w+)\.\d+)$/.exec(require('./package.json').version)?.[2] || 'latest')") | ||
echo "pnpm publish --access public --tag next" | ||
- name: Set next dist-tag | ||
run: | | ||
echo "pnpm dist-tag add @faker-js/faker@$RELEASE_VERSION $DIST_TAG" | ||
- name: Push to Branch | ||
run: | | ||
git push origin $GITHUB_REF_NAME:v$RELEASE_MAJOR |