Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit f4d87b4

Browse files
committed
ci: Introduce new CI publish workflow
1 parent 080b0ba commit f4d87b4

File tree

3 files changed

+48
-8
lines changed

3 files changed

+48
-8
lines changed

.github/workflows/publish.yml

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,52 @@
1+
# Version tags only
2+
13
name: Publish
24

3-
on: [release]
5+
on:
6+
push:
7+
tags:
8+
- v[0-9]+.[0-9]+.[0-9]+
49

510
jobs:
6-
publish-npm:
11+
publish:
12+
name: Publish
713
runs-on: ubuntu-latest
14+
env:
15+
# It'll work with secrets.GITHUB_TOKEN (which is provided by GitHub unconditionally)
16+
# Still then release author would be "github-actions". It's better if it's dedicated repo bot
17+
GITHUB_TOKEN: ${{ secrets.USER_GITHUB_TOKEN }}
818
steps:
9-
- uses: actions/checkout@v2
19+
- name: Checkout repository
20+
uses: actions/checkout@v2
21+
22+
- name: Retrieve node_modules from cache
23+
id: cacheNodeModules
24+
uses: actions/cache@v2
25+
with:
26+
path: |
27+
~/.npm
28+
node_modules
29+
key: npm-v14-${{ runner.os }}-refs/heads/master-${{ hashFiles('package.json') }}
1030

11-
- uses: actions/setup-node@v2
31+
- name: Install Node.js and npm
32+
uses: actions/setup-node@v1
1233
with:
13-
version: 14
14-
registry-url: https://registry.npmjs.org/
34+
node-version: 14.x
35+
registry-url: https://registry.npmjs.org
1536

16-
- run: npm publish
37+
- name: Publish new version
1738
env:
18-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
39+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
40+
run: npm publish
41+
42+
# Note: No need to install dependencies as:
43+
# 1. We have retrieved cached `node_modules` for very same `package.json`
44+
# as stored with recent `master `build
45+
# 2. If for some reason cache retrieval fails `npx` will download and install
46+
# `github-release-from-cc-changelog`
47+
48+
- name: Publish release notes
49+
run: |
50+
TEMP_ARRAY=($(echo $GITHUB_REF | tr "/" "\n"))
51+
TAG=${TEMP_ARRAY[@]: -1}
52+
npx github-release-from-cc-changelog $TAG

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4+

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"format": "prettier --write '{.,lib}/*.{js,md}'",
4242
"lint": "eslint *.js lib/*.js && prettier -c '{.,lib}/*.{js,md}'",
4343
"lint:updated": "pipe-git-updated --ext=js -- eslint",
44+
"prepare-release": "standard-version && prettier --write CHANGELOG.md",
4445
"prettier-check": "prettier -c --ignore-path .gitignore \"**/*.{css,html,js,json,md,yaml,yml}\"",
4546
"prettier-check:updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier -c",
4647
"prettify": "prettier --write --ignore-path .gitignore \"**/*.{css,html,js,json,md,yaml,yml}\"",
@@ -51,6 +52,7 @@
5152
"cross-spawn": "*",
5253
"eslint": "^7.32.0",
5354
"git-list-updated": "^1.2.1",
55+
"github-release-from-cc-changelog": "^2.2.0",
5456
"lodash": "^4.17.21",
5557
"prettier": "^2",
5658
"tape": "*",

0 commit comments

Comments
 (0)