-
Notifications
You must be signed in to change notification settings - Fork 6
151 lines (131 loc) · 4.47 KB
/
manual-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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# This is a basic workflow that is manually triggered
name: Manual Release
on:
workflow_dispatch:
inputs:
bumpPart:
description: 'Bump part (major, minor or patch)'
required: true
default: "minor"
notes:
description: 'Changelog notes'
required: false
permissions:
contents: write
packages: write
jobs:
tag-version:
name: Tag Version
runs-on: ubuntu-latest
outputs:
old_version: ${{ steps.bumpversion.outputs.old_ver }}
version: ${{ steps.bumpversion.outputs.new_ver }}
app_name: ${{ steps.appinfo.outputs.app_name }}
new_sha: ${{ steps.sha.outputs.sha }}
# Validate bump part before moving forward
if: contains(['major', 'minor', 'patch'], ${{ github.event.inputs.bumpPart }})
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Get app info
id: appinfo
run: |
APP_NAME=$(cat splunk-*/app.manifest | jq -r '.info.id.name' | tr _ - )
echo "app_name=${APP_NAME}" >> $GITHUB_OUTPUT
working-directory: packages/
- name: Bump version and push tag
id: bumpversion
uses: jasonamyers/github-bumpversion-action@v1.0.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BUMP: ${{ github.event.inputs.bumpPart }}
- name: Push tags
run: |
remote_repo="https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
git push "${remote_repo}" HEAD:${GITHUB_REF} --follow-tags --tags
- name: Get SHA
id: sha
run: |
sha_new=$(git rev-parse HEAD)
echo "sha=${sha_new}" >> $GITHUB_OUTPUT
build:
name: Generate App Bundle
needs: tag-version
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ needs.tag-version.outputs.new_sha }}
fetch-depth: 0
- name: Excluding images from README
run: |
sed -i '/^!/d' README.md
cp README.md packages/splunk-*/
- name: Bundle app source
run: |
mkdir dist
tar -C packages -zcvf dist/${{ needs.tag-version.outputs.app_name }}_v${{ needs.tag-version.outputs.version }}.tgz ${{ needs.tag-version.outputs.app_name }}/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: app_tgz
path: dist/*
release:
name: Create Release
needs:
- tag-version
- build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Fetch all tags
run: |
git fetch --unshallow --tags
- name: Build changelog message
id: changelog
run: |
tags_no=$(git tag -l | wc -l)
if [[ "${tags_no}" > 1 ]]; then
content=$(git log v${{ needs.tag-version.outputs.old_version }}..v${{ needs.tag-version.outputs.version }} --oneline --decorate --pretty=format:"%s" | tail -n 1)
content="${content//'%'/%25}"
content="${content//$'\n'/%0A}"
content="${content//$'\r'/%0D}"
else
content="Initial release"
fi
echo "message=${content}" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.tag-version.outputs.version }}
release_name: v${{ needs.tag-version.outputs.version }}
body: |
## Changelog
${{ github.event.inputs.notes }}
${{ steps.changelog.outputs.message }}
draft: false
prerelease: false
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: app_tgz
- name: Get artifact name
id: app-name
run: |
app_package=$(ls -1 *gz | xargs basename)
echo "package=${app_package}" >> $GITHUB_OUTPUT
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.app-name.outputs.package }}
asset_name: ${{ steps.app-name.outputs.package }}
asset_content_type: application/tgz