Skip to content

Commit

Permalink
infra(release): publish release
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT committed Jul 2, 2024
1 parent f104dd5 commit 30c5d48
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/publish-release.yml
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

0 comments on commit 30c5d48

Please sign in to comment.