Skip to content

Commit a67f169

Browse files
committed
Add release and publish workflows
1 parent 3adaeb7 commit a67f169

File tree

4 files changed

+83
-0
lines changed

4 files changed

+83
-0
lines changed

.github/release-draft-template.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name-template: 'v$RESOLVED_VERSION 🌻'
2+
tag-template: 'v$RESOLVED_VERSION'
3+
exclude-labels:
4+
- 'skip-changelog'
5+
version-resolver:
6+
minor:
7+
labels:
8+
- 'breaking-change'
9+
default: patch
10+
categories:
11+
- title: 'Breaking changes ⚠️'
12+
label: 'breaking-change'
13+
template: |
14+
## Changes
15+
16+
$CHANGES
17+
18+
Thanks again to $CONTRIBUTORS! 🎉
19+
no-changes-template: 'Changes are coming soon 😎'
20+
sort-direction: 'ascending'
21+
replacers:
22+
- search: '/(?:and )?@dependabot-preview(?:\[bot\])?,?/g'
23+
replace: ''
24+
- search: '/(?:and )?@dependabot(?:\[bot\])?,?/g'
25+
replace: ''
26+
- search: '/(?:and )?@bors(?:\[bot\])?,?/g'
27+
replace: ''
28+
- search: '/(?:and )?@meili-bot,?/g'
29+
replace: ''

.github/workflows/publish.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: publish to npm
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
7+
jobs:
8+
publish-npm:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: actions/setup-node@v1
13+
with:
14+
node-version: 12
15+
registry-url: https://registry.npmjs.org/
16+
- name: Install dependencies
17+
run: yarn install
18+
- name: Build
19+
run: yarn build
20+
- name: Check release validity
21+
run: sh scripts/check-release.sh
22+
- name: Publish
23+
run: npm publish .
24+
env:
25+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
update_release_draft:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: release-drafter/release-drafter@v5
13+
with:
14+
config-name: release-draft-template.yml
15+
env:
16+
GITHUB_TOKEN: ${{ secrets.RELEASE_DRAFTER_TOKEN }}

scripts/check-release.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
# Checking if current tag matches the package version
4+
current_tag=$(echo $GITHUB_REF | tr -d 'refs/tags/v')
5+
file_tag=$(grep '"version":' package.json | cut -d ':' -f 2- | tr -d ' ' | tr -d '"' | tr -d ',')
6+
if [ "$current_tag" != "$file_tag" ]; then
7+
echo "Error: the current tag does not match the version in package file(s)."
8+
echo "$current_tag vs $file_tag"
9+
exit 1
10+
fi
11+
12+
echo 'OK'
13+
exit 0

0 commit comments

Comments
 (0)