From 8937d5c6bc80b97c640c242a689d2e7d16c3206d Mon Sep 17 00:00:00 2001 From: gladiuscode Date: Sat, 1 Feb 2025 10:09:31 +0100 Subject: [PATCH 1/9] chore: update package json info required for npm --- package.json | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 9d3cc00..72e8a65 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,16 @@ "description": "Playground to learn and save all github-actions template I use on my open source projects.", "version": "0.2.0", "packageManager": "yarn@4.6.0", + "author": "Mirko Quaglia (https://github.com/gladiuscode)", + "main": "build/index", + "source": "src/index", + "files": [ + "src", + "build", + "!**/__tests__", + "!**/__fixtures__", + "!**/__mocks__" + ], "scripts": { "release": "release-it", "build": "tsc", @@ -19,5 +29,20 @@ }, "engines": { "node": "=18.20.6" - } + }, + "keywords": [ + "github-actions", + "github", + "actions", + "playground", + "template" + ], + "repository": { + "type": "git", + "url": "https://github.com/gladiuscode/github-actions-playground.git" + }, + "publishConfig": { + "registry": "https://registry.npmjs.org" + }, + "license": "MIT" } From 1a869ff86ba546ee25a1062168d85da1b3670e48 Mon Sep 17 00:00:00 2001 From: gladiuscode Date: Sat, 1 Feb 2025 10:12:40 +0100 Subject: [PATCH 2/9] ci: create release-it-with-npm-and-pr-only template --- .../release-it-with-npm-and-pr-only.yml | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 .github/workflows/release-it-with-npm-and-pr-only.yml diff --git a/.github/workflows/release-it-with-npm-and-pr-only.yml b/.github/workflows/release-it-with-npm-and-pr-only.yml new file mode 100644 index 0000000..03ec0cd --- /dev/null +++ b/.github/workflows/release-it-with-npm-and-pr-only.yml @@ -0,0 +1,81 @@ +name: release-with-npm-and-pr-only + +on: workflow_dispatch + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup + uses: ./.github/actions/setup + + - name: Build + run: yarn build + + - name: Upload Build Artifact + uses: actions/upload-artifact@v4 + with: + name: build-artifact + path: build + + lint: + name: Lint + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup + uses: ./.github/actions/setup + + - name: Lint + run: yarn lint + + release: + name: Release + runs-on: ubuntu-latest + needs: [build, lint] + + steps: + # (1) Create a GitHub App token + # Note: the Github App must be installed on the repository and included in the bypass list of the ruleset. + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.APP_ID }} + private-key: ${{ secrets.PRIVATE_KEY }} + + - name: Checkout + uses: actions/checkout@v4 + with: + # (2) Use the GitHub App token to init the repository + token: ${{ steps.app-token.outputs.token }} + # (3) Fetch all history so that release-it can determine the version + fetch-depth: 0 + + - name: Setup + uses: ./.github/actions/setup + + # (3) Configure Git user + - name: Configure Git User + run: | + git config --global user.name "${GITHUB_ACTOR}" + git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + + - name: Download Build Artifact + uses: actions/download-artifact@v4 + with: + name: build-artifact + + - name: Release + run: yarn release + env: + # (4) Make GITHUB_TOKEN available to release-it but use the GitHub App token + GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} + From adbb97aef3aac7c64019739ae7b9a1f35625a51f Mon Sep 17 00:00:00 2001 From: gladiuscode Date: Sat, 1 Feb 2025 10:18:34 +0100 Subject: [PATCH 3/9] ci: configure release-it to publish npm --- .release-it.json | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.release-it.json b/.release-it.json index 7ba8b92..614c8b7 100644 --- a/.release-it.json +++ b/.release-it.json @@ -7,7 +7,7 @@ "release": true }, "npm": { - "publish": false + "publish": true }, "plugins": { "@release-it/conventional-changelog": { @@ -15,12 +15,10 @@ "name": "angular", "types": { "feat": { - "section": "Features", - "hidden": false + "section": "Features" }, "fix": { - "section": "Bug Fixes", - "hidden": false + "section": "Bug Fixes" } } }, From df97af95a74da1ebf408f0305e279dc54d3afb92 Mon Sep 17 00:00:00 2001 From: gladiuscode Date: Sat, 1 Feb 2025 10:23:24 +0100 Subject: [PATCH 4/9] fix: missing git prefix in repository info --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 72e8a65..2e0de31 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ ], "repository": { "type": "git", - "url": "https://github.com/gladiuscode/github-actions-playground.git" + "url": "git+https://github.com/gladiuscode/github-actions-playground.git" }, "publishConfig": { "registry": "https://registry.npmjs.org" From b43f494a42cdcd6b1525ee7c42688dea0d1ea0f9 Mon Sep 17 00:00:00 2001 From: gladiuscode Date: Sat, 1 Feb 2025 15:11:37 +0100 Subject: [PATCH 5/9] chore: rename package and set version to 1.0.0 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2e0de31..7033c16 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "github-actions-playground", + "name": "ga-playground", "description": "Playground to learn and save all github-actions template I use on my open source projects.", - "version": "0.2.0", + "version": "1.0.0", "packageManager": "yarn@4.6.0", "author": "Mirko Quaglia (https://github.com/gladiuscode)", "main": "build/index", From 3a0787ddca966f010ec335d965294824b5aefa10 Mon Sep 17 00:00:00 2001 From: gladiuscode Date: Sat, 1 Feb 2025 15:22:57 +0100 Subject: [PATCH 6/9] ci: create .npmrc to authenticate with access token --- .npmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..7f0c4e5 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +//registry.npmjs.org/:_authToken=${NPM_ACCESS_TOKEN} From 7750904d401f0f5c866fe36efd1c704041a3aba1 Mon Sep 17 00:00:00 2001 From: gladiuscode Date: Sat, 1 Feb 2025 15:24:54 +0100 Subject: [PATCH 7/9] ci: configure release step to read NPM_ACCESS_TOKEN variable --- .github/workflows/release-it-with-npm-and-pr-only.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release-it-with-npm-and-pr-only.yml b/.github/workflows/release-it-with-npm-and-pr-only.yml index 03ec0cd..af2e393 100644 --- a/.github/workflows/release-it-with-npm-and-pr-only.yml +++ b/.github/workflows/release-it-with-npm-and-pr-only.yml @@ -78,4 +78,6 @@ jobs: env: # (4) Make GITHUB_TOKEN available to release-it but use the GitHub App token GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} + # (5) Make NPM_ACCESS_TOKEN available to release-it and npm publish command + NPM_ACCESS_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} From c32f37d596ca6b6b64a982d5464eae03a0858875 Mon Sep 17 00:00:00 2001 From: gladiuscode Date: Sat, 1 Feb 2025 15:26:47 +0100 Subject: [PATCH 8/9] chore: fix comments --- .github/workflows/release-it-with-npm-and-pr-only.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-it-with-npm-and-pr-only.yml b/.github/workflows/release-it-with-npm-and-pr-only.yml index af2e393..c088d86 100644 --- a/.github/workflows/release-it-with-npm-and-pr-only.yml +++ b/.github/workflows/release-it-with-npm-and-pr-only.yml @@ -62,7 +62,7 @@ jobs: - name: Setup uses: ./.github/actions/setup - # (3) Configure Git user + # (4) Configure Git user - name: Configure Git User run: | git config --global user.name "${GITHUB_ACTOR}" @@ -76,8 +76,8 @@ jobs: - name: Release run: yarn release env: - # (4) Make GITHUB_TOKEN available to release-it but use the GitHub App token + # (5) Make GITHUB_TOKEN available to release-it but use the GitHub App token GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} - # (5) Make NPM_ACCESS_TOKEN available to release-it and npm publish command + # (6) Make NPM_ACCESS_TOKEN available to release-it and npm publish command NPM_ACCESS_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} From c993a62a3c9e7543d96a98add653b59f5b3f1779 Mon Sep 17 00:00:00 2001 From: gladiuscode Date: Sat, 1 Feb 2025 15:27:53 +0100 Subject: [PATCH 9/9] ci: update release script to use --ci and --dry-run --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7033c16..4357f94 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "!**/__mocks__" ], "scripts": { - "release": "release-it", + "release": "release-it --ci --dry-run", "build": "tsc", "lint": "eslint ./src" },