-
Notifications
You must be signed in to change notification settings - Fork 141
78 lines (67 loc) · 2.39 KB
/
github-release.yaml
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
name: github-release
on:
push:
branches:
- beta/v*
tags:
- v*
workflow_dispatch:
inputs:
beta-branch-or-tag-name:
description: The name of the beta branch or tag to release
type: string
required: true
jobs:
github-release:
runs-on: ubuntu-latest
steps:
- name: Set tag name
id: set-tag-name
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
REF_NAME="${{ github.event.inputs.beta-branch-or-tag-name }}"
else
REF_NAME="${{ github.ref_name }}"
fi
echo "ref-name=$REF_NAME" >> $GITHUB_OUTPUT
echo "tag-name=${REF_NAME#beta/}" >> $GITHUB_OUTPUT
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ steps.set-tag-name.outputs.ref-name }}
- name: Set target name for beta branches
id: set-target-name
run: |
if [[ "${{ steps.set-tag-name.outputs.ref-name }}" =~ "beta/" ]]; then
echo "target-name=${{ steps.set-tag-name.outputs.ref-name }}" >> $GITHUB_OUTPUT
fi
- name: Create a local tag for beta branches
run: |
if [ "${{ steps.set-target-name.outputs.target-name }}" != "" ]; then
git tag "${{ steps.set-tag-name.outputs.tag-name }}"
fi
- name: Run generate-changelog
id: generate-changelog
uses: autowarefoundation/autoware-github-actions/generate-changelog@v1
- name: Select verb
id: select-verb
run: |
has_previous_draft=$(gh release view --json isDraft -q ".isDraft" "${{ steps.set-tag-name.outputs.tag-name }}") || true
verb=create
if [ "$has_previous_draft" = "true" ]; then
verb=edit
fi
echo "verb=$verb" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release to GitHub
run: |
gh release ${{ steps.select-verb.outputs.verb }} "${{ steps.set-tag-name.outputs.tag-name }}" \
--draft \
--target "${{ steps.set-target-name.outputs.target-name }}" \
--title "Release ${{ steps.set-tag-name.outputs.tag-name }}" \
--notes "$NOTES"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NOTES: ${{ steps.generate-changelog.outputs.changelog }}