build: give write permission to create releases #6
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release | |
on: | |
push: | |
tags: | |
- "v*.*.*" | |
jobs: | |
build: | |
name: Build and Release APK | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Extract Release Notes | |
id: extract_changelog | |
run: | | |
chmod +x scripts/get-release-notes.sh | |
ReleaseNotes=$(scripts/get-release-notes.sh "${{ github.ref_name }}") | |
if [ $? -ne 0 ]; then | |
echo "Failed to create ReleaseNotes.md" >&2 | |
exit 1 | |
fi | |
echo "$ReleaseNotes" > ./ReleaseNotes.md | |
echo "Release Notes:" | |
cat ./ReleaseNotes.md | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: '21' | |
- name: Cache Gradle | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle | |
- name: Decode keystore file | |
run: | | |
mkdir -p app/keystore | |
echo "${{ secrets.KEYSTORE_FILE_BASE64 }}" | base64 -d > app/keystore/ryan-andrew.jks | |
echo "storeFile=keystore/ryan-andrew.jks" > app/signing.properties | |
echo "storePassword=${{ secrets.STORE_PASSWORD }}" >> app/signing.properties | |
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> app/signing.properties | |
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> app/signing.properties | |
- name: Make Gradle executable | |
run: chmod +x ./gradlew | |
- name: Build Release APK | |
run: ./gradlew assembleRelease | |
- name: Clean up sensitive files | |
run: | | |
rm -f app/keystore/ryan-andrew.jks | |
rm -f app/signing.properties | |
- name: Upload Release Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: SupernoteLinker-Release-APK | |
path: app/build/outputs/apk/release/*.apk | |
- name: Create GitHub Release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ github.ref_name }} | |
name: Release ${{ github.ref_name }} | |
bodyFile: "ReleaseNotes.md" | |
replacesArtifacts: true | |
prerelease: false | |
artifactErrorsFailBuild: true | |
artifacts: "app/build/outputs/apk/release/*.apk" |