Skip to content

Commit 6d11317

Browse files
committed
ci(github-actions): setup basic create release and publish to npm workflows
1 parent 7cad5de commit 6d11317

File tree

3 files changed

+63
-42
lines changed

3 files changed

+63
-42
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Create release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
create-release:
10+
name: Create GitHub Release
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
17+
- name: Get semver number
18+
id: get_semver
19+
env:
20+
TAG_NAME: ${{ github.ref }}
21+
run: echo "::set-output name=num::${TAG_NAME:11}"
22+
23+
- name: Create release on GitHub API
24+
id: create_release
25+
uses: actions/create-release@v1
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
with:
29+
tag_name: ${{ github.ref }}
30+
release_name: "@${{ github.repository }}@${{ steps.get_semver.outputs.num }}"
31+
body: |
32+
:scroll: [Changelog](https://github.com/${{ github.repository }}/blob/v${{ steps.get_semver.outputs.num }}/CHANGELOG.md)
33+
draft: false
34+
prerelease: false

.github/workflows/publish.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Publish
2+
3+
on: registry_package
4+
5+
jobs:
6+
publish:
7+
name: Publish to npm
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
14+
- name: Setup Node
15+
uses: actions/setup-node@v2
16+
with:
17+
node-version: '14.x'
18+
registry-url: 'https://registry.npmjs.org/'
19+
20+
- name: Edit package.json to remove custom registry config
21+
run: |
22+
node -p "const pkg = require('./package.json'); \
23+
delete pkg.publishConfig.registry; \
24+
JSON.stringify(pkg, null, 2)" > pkg.json && mv pkg.json package.json
25+
26+
- name: Publish package to npm registry
27+
run: npm publish
28+
env:
29+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)