-
Notifications
You must be signed in to change notification settings - Fork 1
87 lines (75 loc) · 3 KB
/
create-release-tagged.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
77
78
79
80
81
82
83
84
name: Auto create release notes on create-release/<version> tag
on:
push:
tags:
- create-release/*
jobs:
create_release:
name: Create release notes on create-release/<version> tag
runs-on: judong
timeout-minutes: 5
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Project context
id: context
uses: zero88/[email protected]
- name: Print git references
run: |-
echo "Ref: ${{ github.ref }}"
echo "Head ref: ${{ github.head_ref }}"
echo "Base ref: ${{ github.base_ref }}"
- name: Get version and branch
id: version
run: |
version=$(echo ${{ github.ref }} | cut -d/ -f4)
branch=$(echo ${{ github.event.base_ref }} | cut -d/ -f3)
echo "Version: $version"
echo "version=$version" >> $GITHUB_OUTPUT
echo "branch=$branch" >> $GITHUB_OUTPUT
- name: Create release note
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: v${{ steps.version.outputs.version }}
tag: v${{ steps.version.outputs.version }}
generateReleaseNotes: true
draft: false
prerelease: ${{ contains(github.head_ref, 'master') || contains(github.ref, 'master') }}
- name: Set latest tag
uses: EndBug/latest-tag@latest
with:
tag-name: 'latest_${{ steps.version.outputs.branch }}'
- name: Delete create-release tag
uses: dev-drprasad/[email protected]
with:
tag_name: 'create-release/${{ steps.version.outputs.version }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create message
id: message
if: ${{ always() }}
run: |-
if [ "${{ job.status }}" == "success" ]; then
message=":check_mark_button: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
message="${message} Release notes: https://github.com/${{ github.repository }}/releases/tag/v${{ steps.version.outputs.version }}"
fi
if [ "${{ job.status }}" == "failure" ]; then
message=":cross_mark: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
message="${message} Error create release notes"
fi
if [ "${{ job.status }}" == "canceled" ]; then
message=":cross_mark: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
message="${message} Release notes canceled"
fi
echo "message=${message}" >> $GITHUB_OUTPUT
- name: Write message to file
run: |-
echo "${{ steps.message.outputs.message }}"
echo "${{ steps.message.outputs.message }}" > build.msg