Skip to content

Commit 9e022e5

Browse files
authored
feat: release it with npm pr and inputs (#14)
* feat: create workflow with dry input and handling * build: update release script and remove --ci flag
1 parent 6df7b29 commit 9e022e5

File tree

2 files changed

+96
-1
lines changed

2 files changed

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"!**/__mocks__"
1515
],
1616
"scripts": {
17-
"release": "release-it --ci --dry-run",
17+
"release": "release-it --ci",
1818
"build": "tsc",
1919
"lint": "eslint ./src"
2020
},

0 commit comments

Comments
 (0)