-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (54 loc) · 1.74 KB
/
Copy pathgithub-release.yml
File metadata and controls
62 lines (54 loc) · 1.74 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
name: GitHub Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: Tag to release, for example v5.9.1
required: true
type: string
permissions:
contents: write
jobs:
release:
name: 🚀 Create GitHub Release
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
fetch-depth: 0
- name: 🏷️ Create GitHub Release
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
with:
script: |
const tag = context.eventName === 'workflow_dispatch'
? '${{ inputs.tag }}'
: context.ref.replace('refs/tags/', '');
const version = tag.replace(/^v/, '');
const installBlock = [
'## Install',
'```sh',
`npm install @mcabreradev/filter@${version}`,
`pnpm add @mcabreradev/filter@${version}`,
`yarn add @mcabreradev/filter@${version}`,
'```',
'',
`📦 [View on npm](https://www.npmjs.com/package/@mcabreradev/filter/v/${version})`,
'',
'---',
'',
].join('\n');
const { data: release } = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tag,
name: `Release ${tag}`,
body: installBlock,
generate_release_notes: true,
draft: false,
prerelease: false,
});
console.log(`✅ Release created: ${release.html_url}`);