Skip to content

infra(release): publish release #3

infra(release): publish release

infra(release): publish release #3

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