Skip to content

Commit 07e7dfe

Browse files
authored
feat: create release-it-to-npm-with-pr-only (#11)
* chore: update package json info required for npm * ci: create release-it-with-npm-and-pr-only template * ci: configure release-it to publish npm * fix: missing git prefix in repository info * chore: rename package and set version to 1.0.0 * ci: create .npmrc to authenticate with access token * ci: configure release step to read NPM_ACCESS_TOKEN variable * chore: fix comments * ci: update release script to use --ci and --dry-run
1 parent 731bfd5 commit 07e7dfe

File tree

4 files changed

+116
-9
lines changed

4 files changed

+116
-9
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: release-with-npm-and-pr-only
2+
3+
on: workflow_dispatch
4+
5+
jobs:
6+
build:
7+
name: Build
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
- name: Setup
15+
uses: ./.github/actions/setup
16+
17+
- name: Build
18+
run: yarn build
19+
20+
- name: Upload Build Artifact
21+
uses: actions/upload-artifact@v4
22+
with:
23+
name: build-artifact
24+
path: build
25+
26+
lint:
27+
name: Lint
28+
runs-on: ubuntu-latest
29+
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
34+
- name: Setup
35+
uses: ./.github/actions/setup
36+
37+
- name: Lint
38+
run: yarn lint
39+
40+
release:
41+
name: Release
42+
runs-on: ubuntu-latest
43+
needs: [build, lint]
44+
45+
steps:
46+
# (1) Create a GitHub App token
47+
# Note: the Github App must be installed on the repository and included in the bypass list of the ruleset.
48+
- uses: actions/create-github-app-token@v1
49+
id: app-token
50+
with:
51+
app-id: ${{ vars.APP_ID }}
52+
private-key: ${{ secrets.PRIVATE_KEY }}
53+
54+
- name: Checkout
55+
uses: actions/checkout@v4
56+
with:
57+
# (2) Use the GitHub App token to init the repository
58+
token: ${{ steps.app-token.outputs.token }}
59+
# (3) Fetch all history so that release-it can determine the version
60+
fetch-depth: 0
61+
62+
- name: Setup
63+
uses: ./.github/actions/setup
64+
65+
# (4) Configure Git user
66+
- name: Configure Git User
67+
run: |
68+
git config --global user.name "${GITHUB_ACTOR}"
69+
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
70+
71+
- name: Download Build Artifact
72+
uses: actions/download-artifact@v4
73+
with:
74+
name: build-artifact
75+
76+
- name: Release
77+
run: yarn release
78+
env:
79+
# (5) Make GITHUB_TOKEN available to release-it but use the GitHub App token
80+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
81+
# (6) Make NPM_ACCESS_TOKEN available to release-it and npm publish command
82+
NPM_ACCESS_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
83+

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//registry.npmjs.org/:_authToken=${NPM_ACCESS_TOKEN}

.release-it.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,18 @@
77
"release": true
88
},
99
"npm": {
10-
"publish": false
10+
"publish": true
1111
},
1212
"plugins": {
1313
"@release-it/conventional-changelog": {
1414
"preset": {
1515
"name": "angular",
1616
"types": {
1717
"feat": {
18-
"section": "Features",
19-
"hidden": false
18+
"section": "Features"
2019
},
2120
"fix": {
22-
"section": "Bug Fixes",
23-
"hidden": false
21+
"section": "Bug Fixes"
2422
}
2523
}
2624
},

package.json

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
{
2-
"name": "github-actions-playground",
2+
"name": "ga-playground",
33
"description": "Playground to learn and save all github-actions template I use on my open source projects.",
4-
"version": "0.2.0",
4+
"version": "1.0.0",
55
"packageManager": "[email protected]",
6+
"author": "Mirko Quaglia <[email protected]> (https://github.com/gladiuscode)",
7+
"main": "build/index",
8+
"source": "src/index",
9+
"files": [
10+
"src",
11+
"build",
12+
"!**/__tests__",
13+
"!**/__fixtures__",
14+
"!**/__mocks__"
15+
],
616
"scripts": {
7-
"release": "release-it",
17+
"release": "release-it --ci --dry-run",
818
"build": "tsc",
919
"lint": "eslint ./src"
1020
},
@@ -19,5 +29,20 @@
1929
},
2030
"engines": {
2131
"node": "=18.20.6"
22-
}
32+
},
33+
"keywords": [
34+
"github-actions",
35+
"github",
36+
"actions",
37+
"playground",
38+
"template"
39+
],
40+
"repository": {
41+
"type": "git",
42+
"url": "git+https://github.com/gladiuscode/github-actions-playground.git"
43+
},
44+
"publishConfig": {
45+
"registry": "https://registry.npmjs.org"
46+
},
47+
"license": "MIT"
2348
}

0 commit comments

Comments
 (0)