From f827ad5954ca85333031e008ffdb890ef29aff22 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Wed, 3 Jul 2024 00:13:57 +0200 Subject: [PATCH 1/4] infra(release): publish release --- .github/workflows/publish-release.yml | 65 +++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/publish-release.yml diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 00000000000..6260edda1ff --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,65 @@ +name: Publish Release + +on: + release: + types: [published] + +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 + with: + fetch-depth: 0 # we want to push the release branch later + + - 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 + env: + CYPRESS_INSTALL_BINARY: 0 + + - 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: | + echo -e "$(grep -P '## 📙 API Documentation' -B 10000 README.md)\n\n- [Getting Started Guide](https://fakerjs.dev/guide/)\n- [API Reference](https://fakerjs.dev/api/)\n\n$(grep -P '## 🚀 Features' -A 10000 README.md)" > README.md + sed -i "s|/fakerjs.dev/|/v$RELEASE_MAJOR.fakerjs.dev/|g" 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: | + pnpm publish --tag next --no-git-checks + env: + CYPRESS_INSTALL_BINARY: 0 + + - name: Set latest/next dist-tag + run: | + pnpm dist-tag add @faker-js/faker@$RELEASE_VERSION $DIST_TAG + + - name: Push to Release Branch + run: | + git push origin $GITHUB_REF_NAME:v$RELEASE_MAJOR From 4fca298c9d1ad038b12196cb1be80dbc81b2cc36 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Wed, 3 Jul 2024 00:56:51 +0200 Subject: [PATCH 2/4] chore: pin versions --- .github/workflows/publish-release.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 6260edda1ff..a59189d9f4c 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -18,15 +18,15 @@ jobs: fetch-depth: 0 # we want to push the release branch later - name: Install pnpm - uses: pnpm/action-setup@v2 + uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 - - name: Set node version to 20 - uses: actions/setup-node@v4 + - name: Set node version to 22 + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: - node-version: 20 + node-version: 22 cache: 'pnpm' - - name: Prepare + - name: Install deps run: pnpm install --frozen-lockfile env: CYPRESS_INSTALL_BINARY: 0 From 04e3fd7b5a866410446b0762e9bf5d19686e8dc3 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Wed, 3 Jul 2024 00:57:32 +0200 Subject: [PATCH 3/4] chore: rename --- .github/workflows/publish-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index a59189d9f4c..340d67f4d6b 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -31,7 +31,7 @@ jobs: env: CYPRESS_INSTALL_BINARY: 0 - - name: Gather release info + - name: Gather release information run: | RELEASE_VERSION=$(jq -r '.version' package.json) echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV From a6d979fc1aee585db568aec7056947c1803cc39d Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Wed, 3 Jul 2024 01:02:38 +0200 Subject: [PATCH 4/4] Apply suggestions from code review --- .github/workflows/publish-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 340d67f4d6b..29379a96bc1 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -11,6 +11,7 @@ jobs: publish: name: Publish Release runs-on: ubuntu-latest + steps: - name: Checkout uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7