Skip to content

Commit 50e84e0

Browse files
authored
Merge branch 'main' into imjohnbo/markdown-links
2 parents fbe5a82 + 909ae9d commit 50e84e0

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

.github/actions/setup/action.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Setup project
2+
description: Sets up the repo code, Node.js, and npm dependencies
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Set up Node.js
8+
uses: actions/setup-node@v2
9+
with:
10+
node-version: '16.x'
11+
cache: npm
12+
registry-url: https://registry.npmjs.org
13+
- name: Install npm dependencies
14+
run: npm ci
15+
shell: bash

.github/workflows/release.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Release and publish
2+
3+
# Inspired by https://github.com/MylesBorins/node-osc/blob/959b9c83972a67390a351d333b23db3972ca7b46/.github/workflows/bump-version.yml and
4+
# https://github.com/MylesBorins/node-osc/blob/74b563c83736a04c4a37acbff9d7bb1f01a00f57/.github/workflows/create-release.yml
5+
6+
on:
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: Semver descriptor for new version ("major", "minor", or "patch")
11+
required: true
12+
13+
jobs:
14+
bump-version:
15+
name: Bump package version
16+
runs-on: ubuntu-latest
17+
outputs:
18+
new-tag: ${{ steps.new-tag.outputs.new-tag }}
19+
steps:
20+
- name: Checkout ref
21+
uses: actions/checkout@v2
22+
- name: Preparation
23+
uses: ./.github/actions/setup
24+
- name: Perform last-minute tests
25+
run: npm test
26+
- name: Configure Git
27+
run: |
28+
git config user.name "GitHub Actions"
29+
git config user.email "[email protected]"
30+
- name: Bump package version
31+
run: npm version ${{ github.event.inputs.version }}
32+
- name: Push back to GitHub
33+
run: git push origin main --follow-tags
34+
- name: Set output to new version
35+
id: new-tag
36+
run: |
37+
version=$(jq -r .version < package.json)
38+
echo "::set-output name=new-tag::v$version"
39+
create-release:
40+
name: Create GitHub release
41+
runs-on: ubuntu-latest
42+
needs: bump-version
43+
steps:
44+
- name: Checkout ref
45+
uses: actions/checkout@v2
46+
with:
47+
ref: ${{ needs.bump-version.outputs.new-tag }}
48+
- name: Preparation
49+
uses: ./.github/actions/setup
50+
- name: Create release
51+
uses: actions/github-script@v5
52+
with:
53+
github-token: ${{ secrets.GITHUB_TOKEN }}
54+
script: |
55+
await github.request(`POST /repos/${{ github.repository }}/releases`, {
56+
tag_name: "${{ needs.bump-version.outputs.new-tag }}",
57+
generate_release_notes: true
58+
})
59+
publish:
60+
name: Publish to npm
61+
runs-on: ubuntu-latest
62+
needs: [bump-version, create-release]
63+
steps:
64+
- name: Checkout ref
65+
uses: actions/checkout@v2
66+
with:
67+
ref: ${{ needs.bump-version.outputs.new-tag }}
68+
- name: Preparation
69+
uses: ./.github/actions/setup
70+
- name: Build package
71+
run: npm run build --if-present
72+
- name: Publish
73+
run: npm publish --access public
74+
env:
75+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)