-
Notifications
You must be signed in to change notification settings - Fork 37
83 lines (72 loc) · 2.49 KB
/
release.yaml
File metadata and controls
83 lines (72 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Release to NPM
# Controls when the action will run. Triggers the workflow on pushed tags
on:
push:
tags:
- '*'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
permissions:
contents: write # Required for creating releases
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history for changelog generation
# Set up Node
- name: Use Node 20
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
# Run install dependencies
- name: Install dependencies
run: npm ci
- name: Build
run: npm run prepublish
- name: Test
run: npm test
- name: Get previous tag
id: get_previous_tag
run: |
# Get the previous tag (excluding the current one)
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "")
echo "tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT
echo "Previous tag: $PREVIOUS_TAG"
# Generate changelog for the release
- name: Build Changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
configuration: ".github/changelog-config.json"
fromTag: ${{ steps.get_previous_tag.outputs.tag }}
toTag: ${{ github.ref_name }}
ignorePreReleases: true
# Create GitHub Release
- name: Create GitHub Release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
body: |
## What's Changed
${{ steps.build_changelog.outputs.changelog }}
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ steps.get_previous_tag.outputs.tag }}...${{ github.ref_name }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Publish to npm
- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}