-
Notifications
You must be signed in to change notification settings - Fork 1.3k
76 lines (63 loc) · 2.16 KB
/
release.yml
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
name: release
on:
workflow_dispatch:
inputs:
publish:
description: 'If true, does not create the release as a draft.'
required: false
type: boolean
default: false
permissions: {}
jobs:
release:
runs-on: [ ubuntu-latest ]
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
permissions:
contents: write
issues: write
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Get version
id: get-version
shell: pwsh
run: |
$properties = Join-Path "." "Directory.Build.props"
$xml = [xml](Get-Content $properties)
$version = $xml.SelectSingleNode('Project/PropertyGroup/VersionPrefix').InnerText
"version=${version}" >> $env:GITHUB_OUTPUT
- name: Create release
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
DRAFT: ${{ inputs.publish != true }}
VERSION: ${{ steps.get-version.outputs.version }}
with:
script: |
const { repo, owner } = context.repo;
const draft = process.env.DRAFT === 'true';
const version = process.env.VERSION;
const tag_name = `v${version}`;
const name = tag_name;
const { data: notes } = await github.rest.repos.generateReleaseNotes({
owner,
repo,
tag_name,
target_commitish: process.env.DEFAULT_BRANCH,
});
const body = notes.body
.split('\n')
.filter((line) => !line.includes(' @dependabot '))
.filter((line) => !line.includes(' @github-actions '))
.join('\n');
const { data: release } = await github.rest.repos.createRelease({
owner,
repo,
tag_name,
name,
body,
draft,
});
core.notice(`Created release ${release.name}: ${release.html_url}`);