This repository was archived by the owner on Dec 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (112 loc) · 4.39 KB
/
Copy pathgithub-release.yml
File metadata and controls
133 lines (112 loc) · 4.39 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
# GitHub Actions Workflow for Creating Releases with APKs
name: Create GitHub Release with APKs
on:
push:
tags:
- 'v*' # Triggers on version tags like v1.1.5
# Prevent concurrent releases for the same tag
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
create-release:
runs-on: ubuntu-latest
timeout-minutes: 30
# Minimal permissions following security best practices
permissions:
contents: write # Required to create releases and upload assets
id-token: write # Required for OIDC token generation
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4.0.0
# Pin to commit SHA for security
# uses: gradle/actions/setup-gradle@v4.0.0
# uses: gradle/actions/setup-gradle@b6e2e7e8e6e5e2e7e8e6e5e2e7e8e6e5e2e7e8e6 # Example SHA, replace with actual latest SHA
with:
gradle-home-cache-cleanup: true
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Build debug APK
run: ./gradlew assembleDebug
- name: Decode Keystore (for signed APK)
run: |
if [ -n "$KEYSTORE_BASE64" ]; then
echo "$KEYSTORE_BASE64" | base64 --decode > ${{ github.workspace }}/release-keystore.jks
echo "Keystore decoded successfully"
else
echo "No keystore configured - APK will be unsigned"
fi
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
- name: Build release APK (signed if keystore available)
run: |
if [ -f "${{ github.workspace }}/release-keystore.jks" ]; then
echo "Building signed release APK..."
./gradlew assembleRelease
else
echo "Building unsigned release APK..."
./gradlew assembleRelease
fi
env:
KEYSTORE_FILE: ${{ github.workspace }}/release-keystore.jks
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
- name: Find APK files
id: find-apks
run: |
DEBUG_APK=$(find . -name "*debug*.apk" -type f | head -1)
RELEASE_APK=$(find . -name "*release*.apk" -type f | head -1)
echo "debug_apk=$DEBUG_APK" >> $GITHUB_OUTPUT
echo "release_apk=$RELEASE_APK" >> $GITHUB_OUTPUT
echo "Found Debug APK: $DEBUG_APK"
echo "Found Release APK: $RELEASE_APK"
- name: Extract version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Generate changelog
id: changelog
run: |
# Try to get commits since last tag, fallback to last 10 commits
LAST_TAG=$(git describe --tags --abbrev=0 HEAD^1 2>/dev/null || echo "")
if [ -n "$LAST_TAG" ]; then
CHANGELOG=$(git log --pretty=format:"- %s" $LAST_TAG..HEAD)
else
CHANGELOG=$(git log --pretty=format:"- %s" -10)
fi
# Create release notes
cat > release_notes.md << EOF
## Notely Capture v${{ steps.version.outputs.version }}
### Changes in this release:
$CHANGELOG
### Downloads:
- **notely-capture-debug.apk**: Debug build for testing
- **notely-capture-release.apk**: Release build for production use
### Installation:
1. Download the APK file
2. Enable "Install from unknown sources" in Android settings
3. Install the APK file
Built from commit: ${{ github.sha }}
EOF
- name: Create GitHub Release with APKs
uses: softprops/action-gh-release@e6c4e2b1e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2 # Replace with the latest commit SHA from https://github.com/softprops/action-gh-release/commits/main
with:
name: Notely Capture v${{ steps.version.outputs.version }}
body_path: release_notes.md
draft: false
prerelease: false
files: |
${{ steps.find-apks.outputs.debug_apk }}
${{ steps.find-apks.outputs.release_apk }}
fail_on_unmatched_files: false