Skip to content

Commit 103f7aa

Browse files
committed
Added semi-automated release pipeline
1 parent fe00d66 commit 103f7aa

File tree

2 files changed

+155
-0
lines changed

2 files changed

+155
-0
lines changed

.bumpversion.cfg

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[bumpversion]
2+
current_version = 1.3.1
3+
commit = True
4+
tag = True
5+
6+
[bumpversion:file:app.manifest]
7+
search = "version": "{current_version}"
8+
replace = "version": "{new_version}"
9+
10+
[bumpversion:file:default/app.conf]
11+
search = version = {current_version}
12+
replace = version = {new_version}
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# This is a basic workflow that is manually triggered
2+
3+
name: Manual Release
4+
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
bumpPart:
9+
description: 'Bump part (major, minor or patch)'
10+
required: true
11+
default: "minor"
12+
notes:
13+
description: 'Changelog notes'
14+
required: false
15+
16+
jobs:
17+
tag-version:
18+
name: Tag Version
19+
runs-on: ubuntu-latest
20+
outputs:
21+
old_version: ${{ steps.bumpversion.outputs.old_ver }}
22+
version: ${{ steps.bumpversion.outputs.new_ver }}
23+
new_sha: ${{ steps.sha.outputs.sha }}
24+
# Validate bump part before moving forward
25+
if: contains(['major', 'minor', 'patch'], ${{ github.event.inputs.bumpPart }})
26+
steps:
27+
- name: Checkout source
28+
uses: actions/checkout@v2
29+
30+
- name: Bump version and push tag
31+
id: bumpversion
32+
uses: jaumann/[email protected]
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
DEFAULT_BUMP: ${{ github.event.inputs.bumpPart }}
36+
- name: Push tags
37+
run: |
38+
remote_repo="https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
39+
git push "${remote_repo}" HEAD:${GITHUB_REF} --follow-tags --tags
40+
41+
- name: Get SHA
42+
id: sha
43+
run: |
44+
sha_new=$(git rev-parse HEAD)
45+
echo "::set-output name=sha::$sha_new"
46+
47+
build:
48+
name: Generate App Bundle
49+
needs: tag-version
50+
runs-on: ubuntu-latest
51+
steps:
52+
- name: Checkout code
53+
uses: actions/checkout@v2
54+
with:
55+
ref: ${{ needs.tag-version.outputs.new_sha }}
56+
fetch-depth: 0
57+
58+
- name: Fetch and set app info
59+
id: appinfo
60+
run: |
61+
APP_NAME=$(echo "$APP_ID" | tr _ - )
62+
echo "::set-output name=app_name::${APP_NAME}"
63+
64+
- name: Excluding images from README
65+
run: |
66+
sed -i '/^!/d' README.md
67+
68+
- name: Bundle app source
69+
run: |
70+
mkdir dist
71+
tar -zcvf dist/${{ steps.appinfo.outputs.app_name }}_v${{ needs.tag-version.outputs.version }}.tgz --exclude='.[^/]*' --exclude=./dist .
72+
73+
- name: Upload artifact
74+
uses: actions/upload-artifact@v2
75+
with:
76+
name: app_tgz
77+
path: dist/${{ steps.appinfo.outputs.app_name }}_v${{ needs.tag-version.outputs.version }}.tgz
78+
79+
release:
80+
name: Create Release
81+
needs:
82+
- tag-version
83+
- build
84+
runs-on: ubuntu-latest
85+
steps:
86+
- name: Checkout code
87+
uses: actions/checkout@v2
88+
89+
- name: Fetch all tags
90+
run: |
91+
git fetch --unshallow --tags
92+
93+
- name: Build changelog message
94+
id: changelog
95+
run: |
96+
tags_no=$(git tag -l | wc -l)
97+
if [[ "${tags_no}" > 1 ]]; then
98+
content=$(git log v${{ needs.tag-version.outputs.old_version }}..v${{ needs.tag-version.outputs.version }} --oneline --decorate --pretty=format:"%s" | tail -n 1)
99+
content="${content//'%'/%25}"
100+
content="${content//$'\n'/%0A}"
101+
content="${content//$'\r'/%0D}"
102+
else
103+
content="Initial release"
104+
fi
105+
echo "::set-output name=message::${content}"
106+
107+
- name: Create Release
108+
id: create_release
109+
uses: actions/create-release@v1
110+
env:
111+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112+
with:
113+
tag_name: v${{ needs.tag-version.outputs.version }}
114+
release_name: v${{ needs.tag-version.outputs.version }}
115+
body: |
116+
## Changelog
117+
${{ github.event.inputs.notes }}
118+
119+
${{ steps.changelog.outputs.message }}
120+
draft: false
121+
prerelease: false
122+
123+
- name: Download artifact
124+
uses: actions/download-artifact@v2
125+
with:
126+
name: app_tgz
127+
128+
- name: Get artifact name
129+
id: app-name
130+
run: |
131+
app_package=$(ls -1 *gz | xargs basename)
132+
echo "::set-output name=package::${app_package}"
133+
134+
- name: Upload Release Asset
135+
id: upload-release-asset
136+
uses: actions/upload-release-asset@v1
137+
env:
138+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
139+
with:
140+
upload_url: ${{ steps.create_release.outputs.upload_url }}
141+
asset_path: ${{ steps.app-name.outputs.package }}
142+
asset_name: ${{ steps.app-name.outputs.package }}
143+
asset_content_type: application/tgz

0 commit comments

Comments
 (0)