Repository navigation
133 lines (129 loc) · 5.15 KB
/
Copy pathrelease.yml
File metadata and controls
133 lines (129 loc) · 5.15 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
name: Release
on:
push:
branches: [release]
permissions:
contents: write
concurrency:
group: stable-release
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 30
env:
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
steps:
- name: Validate release signing secrets
run: |
missing=()
for name in \
ANDROID_KEYSTORE_BASE64 \
ANDROID_KEYSTORE_PASSWORD \
ANDROID_KEY_ALIAS \
ANDROID_KEY_PASSWORD; do
if [[ -z "${!name}" ]]; then
missing+=("$name")
fi
done
if (( ${#missing[@]} )); then
printf 'Missing GitHub Actions repository secret: %s\n' "${missing[@]}" >&2
echo 'See README.md#build-a-signed-release for setup instructions.' >&2
exit 1
fi
- uses: actions/checkout@v5
- uses: cachix/install-nix-action@v31
- uses: cachix/cachix-action@v16
with:
name: devenv
- name: Install devenv
run: nix profile add nixpkgs#devenv
- name: Read and validate release version
run: |
. ./version.properties
# QOwnNotes-style YY.M.N: unpadded month and a zero-based monthly counter.
[[ "$VERSION_NAME" =~ ^[0-9]{2}\.([1-9]|1[0-2])\.(0|[1-9][0-9]*)$ ]]
[[ "$VERSION_CODE" =~ ^[1-9][0-9]*$ ]]
store_changelog="fastlane/metadata/android/en-US/changelogs/$VERSION_CODE.txt"
test -s "$store_changelog"
(( $(wc -m < "$store_changelog") <= 500 ))
{
echo "VERSION_NAME=$VERSION_NAME"
echo "VERSION_CODE=$VERSION_CODE"
echo "RELEASE_TAG=v$VERSION_NAME"
} >> "$GITHUB_ENV"
- name: Verify release does not exist
env:
GH_TOKEN: ${{ github.token }}
run: |
if git ls-remote --exit-code --tags origin "refs/tags/$RELEASE_TAG"; then
echo "Tag $RELEASE_TAG already exists" >&2
exit 1
fi
if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
echo "Release $RELEASE_TAG already exists" >&2
exit 1
fi
- name: Extract release notes from changelog
run: |
awk -v version="$VERSION_NAME" '
BEGIN { heading = "## [" version "]" }
capture && /^## \[/ { exit }
$0 == heading || index($0, heading " - ") == 1 { capture = 1 }
capture { print }
END { if (!capture) exit 1 }
' CHANGELOG.md > "$RUNNER_TEMP/release-notes.md"
test -s "$RUNNER_TEMP/release-notes.md"
- name: Verify unsigned F-Droid build
run: |
devenv shell -- just check-fdroid-metadata build-fdroid
cp app/build/outputs/apk/release/app-release-unsigned.apk \
"$RUNNER_TEMP/fdroid-unsigned.apk"
- name: Restore signing keystore
env:
ANDROID_KEYSTORE_PATH: ${{ runner.temp }}/qownnotes-release.jks
run: |
printf '%s' "$ANDROID_KEYSTORE_BASE64" | base64 --decode > "$ANDROID_KEYSTORE_PATH"
- name: Check and build signed release
env:
ANDROID_KEYSTORE_PATH: ${{ runner.temp }}/qownnotes-release.jks
run: |
devenv shell -- ./gradlew --no-configuration-cache \
spotlessCheck test lintRelease :app:licensee assembleRelease bundleRelease
# ANDROID_HOME is intentionally expanded inside the devenv shell.
# shellcheck disable=SC2016
devenv shell -- bash -c \
'"$ANDROID_HOME/build-tools/36.0.0/apksigner" verify "$1"' \
_ app/build/outputs/apk/release/app-release.apk
devenv shell -- apksigcopier compare --unsigned \
app/build/outputs/apk/release/app-release.apk \
"$RUNNER_TEMP/fdroid-unsigned.apk"
- name: Verify and prepare release packages
run: |
mkdir release-files
cp app/build/outputs/apk/release/app-release.apk \
"release-files/QOwnNotes-Mobile-$VERSION_NAME.apk"
cp app/build/outputs/bundle/release/app-release.aab \
"release-files/QOwnNotes-Mobile-$VERSION_NAME.aab"
(cd release-files && sha256sum \
"QOwnNotes-Mobile-$VERSION_NAME.apk" \
"QOwnNotes-Mobile-$VERSION_NAME.aab" > SHA256SUMS)
- name: Create draft GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "$RELEASE_TAG" \
"release-files/QOwnNotes-Mobile-$VERSION_NAME.apk" \
"release-files/QOwnNotes-Mobile-$VERSION_NAME.aab" \
release-files/SHA256SUMS \
--target "$GITHUB_SHA" \
--title "QOwnNotes Mobile $VERSION_NAME" \
--notes-file "$RUNNER_TEMP/release-notes.md" \
--draft
- name: Publish GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: gh release edit "$RELEASE_TAG" --draft=false --latest