-
Notifications
You must be signed in to change notification settings - Fork 17
131 lines (110 loc) · 4.34 KB
/
draft-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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
###########################################################################################################
#
# This workflow creates a draft release into GitHub's releases section.
#
# It is automatically started, when a "Version: x.y.z" PR is merged.
# Its progress is commented at the "Version: x.y.z" PR.
#
# The workflow can also be started manually, if necessary.
#
# When the workflow is finished, one must visit https://github.com/axoflow/axosyslog/releases,
# double check the generated draft release, and manually release it.
#
###########################################################################################################
name: Draft release
on:
workflow_dispatch:
pull_request:
types: [closed]
env:
GITHUB_TOKEN: ${{ secrets.PAT_FOR_ACTIONS }}
WORKFLOW_NAME: "**Draft release** workflow"
CURRENT_WORKFLOW_RUN_URL: https://github.com/${{ github.repository_owner }}/axosyslog/actions/runs/${{ github.run_id }}
RELEASES_URL: https://github.com/${{ github.repository_owner }}/axosyslog/releases
jobs:
create-release-tarball:
runs-on: ubuntu-latest
if: (github.event_name == 'workflow_dispatch') ||
(github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'version-bump'))
outputs:
RELEASE_TAG: ${{ steps.setup-environment.outputs.RELEASE_TAG }}
RELEASE_NAME: ${{ steps.setup-environment.outputs.RELEASE_NAME }}
TARBALL_NAME: ${{ steps.setup-environment.outputs.TARBALL_NAME }}
steps:
- name: Checkout AxoSyslog source
uses: actions/checkout@v4
- name: "Comment: job started"
if: github.event_name == 'pull_request'
run: |
COMMENT="${WORKFLOW_NAME} started: ${CURRENT_WORKFLOW_RUN_URL}."
gh pr comment \
"${{ github.event.number }}" \
--body "${COMMENT}"
- name: Setup environment
id: setup-environment
run: |
. .github/workflows/gh-tools.sh
VERSION=`cat VERSION.txt`
RELEASE_TAG=axosyslog-$VERSION
RELEASE_NAME=${RELEASE_TAG}
TARBALL_NAME=${RELEASE_NAME}.tar.gz
TARBALL_PATH=dbld/release/${VERSION}/${TARBALL_NAME}
gh_export VERSION RELEASE_TAG TARBALL_PATH
gh_output RELEASE_TAG RELEASE_NAME TARBALL_NAME
- name: "DBLD: release"
run: |
./dbld/rules release VERSION=${VERSION}
- name: Store release tarball as artifact
uses: actions/upload-artifact@v4
with:
name: release-tarball
path: ${{ env.TARBALL_PATH }}
if-no-files-found: error
create-packages:
needs: create-release-tarball
uses: ./.github/workflows/create-packages.yml
with:
source-tarball-artifact-name: release-tarball
dbld-image-mode: build
# upload-packages:
# needs: create-packages
# uses: ./.github/workflows/upload-packages.yml
# with:
# pkg-type: stable
# secrets:
# azure-sas-token: ${{ secrets.AZURE_SAS_TOKEN }}
create-draft-release:
runs-on: ubuntu-latest
needs: [create-release-tarball, create-packages] # TODO replace with upload-packages
steps:
- name: Checkout AxoSyslog source
uses: actions/checkout@v4
- name: Download release tarball artifact
uses: actions/download-artifact@v4
with:
name: release-tarball
- name: Create draft release
run: |
gh release create \
"${{ needs.create-release-tarball.outputs.RELEASE_TAG }}" \
"${{ needs.create-release-tarball.outputs.TARBALL_NAME }}" \
--draft \
--title "${{ needs.create-release-tarball.outputs.RELEASE_NAME }}" \
--notes-file "NEWS.md"
comment-workflow-result:
runs-on: ubuntu-latest
needs: create-draft-release
if: always() && (github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'version-bump'))
steps:
- name: "Comment: job status"
run: |
if [[ "${{ needs.create-draft-release.result }}" = "success" ]]
then
COMMENT="${WORKFLOW_NAME} finished successfully. Please check the Releases page: ${RELEASES_URL}"
else
COMMENT="${WORKFLOW_NAME} failed."
fi
gh pr comment \
--repo "${{ github.repository }}" \
"${{ github.event.number }}" \
--body "${COMMENT}"