-
Notifications
You must be signed in to change notification settings - Fork 53
179 lines (158 loc) · 5.29 KB
/
Copy pathrelease.yaml
File metadata and controls
179 lines (158 loc) · 5.29 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Build the app
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+'
permissions:
contents: write
env:
RELEASE_VERSION: ${{ github.ref_name }}
jobs:
create-release:
name: create-release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Build Changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v3
with:
configuration: ".github/changelog_configuration.json"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare Slack notification contents
run: |
set -euo pipefail
changelog=$(cat << EOH
${{ steps.build_changelog.outputs.changelog }}
EOH
)
messageWithoutNewlines=$(echo "${changelog}" | awk '{printf "%s\\n", $0}')
messageWithoutDoubleQuotes=$(echo "${messageWithoutNewlines}" | sed "s/\"/'/g")
echo "${messageWithoutDoubleQuotes}" > slack-changelog
- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
if [[ "${{ env.RELEASE_VERSION }}" == *"-alpha."* ]] || [[ "${{ env.RELEASE_VERSION }}" == *"-beta."* ]]; then
gh release view "${{ env.RELEASE_VERSION }}" >/dev/null 2>&1 || \
gh release create "${{ env.RELEASE_VERSION }}" \
--title "${{ env.RELEASE_VERSION }}" \
--prerelease
else
gh release view "${{ env.RELEASE_VERSION }}" >/dev/null 2>&1 || \
gh release create "${{ env.RELEASE_VERSION }}" \
--title "${{ env.RELEASE_VERSION }}" \
--notes "${{ steps.build_changelog.outputs.changelog }}"
fi
- name: Upload metadata artifact
uses: actions/upload-artifact@v4
with:
name: metadata
path: slack-changelog
build-release:
name: build-release
needs: [create-release]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Setup keystore
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
run: echo "$KEYSTORE_BASE64" | base64 -d > app/simplelogin.keystore
- name: Build application
env:
KEYSTORE_KEY_ALIAS: ${{ secrets.KEYSTORE_KEY_ALIAS }}
KEYSTORE_KEY_PASSWORD: ${{ secrets.KEYSTORE_KEY_PASSWORD }}
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
run: ./gradlew assembleRelease
- name: Prepare APKs
run: |
set -euo pipefail
mkdir -p apks
cp app/build/outputs/apk/playstore/release/app-playstore-release.apk apks/
cp app/build/outputs/apk/fdroid/release/app-fdroid-release.apk apks/
- name: Upload APKs artifact
uses: actions/upload-artifact@v4
with:
name: apks
path: apks/
upload-assets:
name: upload-assets
needs: [build-release]
runs-on: ubuntu-latest
steps:
- name: Download APKs
uses: actions/download-artifact@v4
with:
name: apks
path: apks
- name: Download metadata
uses: actions/download-artifact@v4
with:
name: metadata
path: metadata
- name: Upload APKs to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
gh release upload "${{ env.RELEASE_VERSION }}" --clobber --repo "${{ github.repository }}" \
"apks/app-playstore-release.apk#simplelogin-playstore-${{ env.RELEASE_VERSION }}.apk" \
"apks/app-fdroid-release.apk#simplelogin-fdroid-${{ env.RELEASE_VERSION }}.apk"
- name: Read Slack changelog
run: |
set -euo pipefail
{
echo 'SLACK_CHANGELOG<<EOF'
cat metadata/slack-changelog
echo EOF
} >> "$GITHUB_ENV"
- name: Post notification to Slack
uses: slackapi/slack-github-action@v1.19.0
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "New tag created on SimpleLogin Android",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Tag: ${{ github.ref_name }}* (${{ github.sha }})"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Changelog:*\n${{ env.SLACK_CHANGELOG }}"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}