Skip to content

Commit

Permalink
Add automated release publishing to CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
javulticat committed Jan 4, 2024
1 parent c01d5b0 commit d8ae563
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 6 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: CD

on:
push:
# tags:
# - "v?[0-9]+.[0-9]+.[0-9]+(-[0-9]?)?"

jobs:
publish-release:
runs-on: ubuntu-latest
permissions:
contents: write
env:
tag: v0.26.1-1
steps:
- name: Checkout code repository
uses: actions/checkout@v4
# - name: Setup Java
# uses: actions/setup-java@v4
# with:
# distribution: temurin
# java-version: 17
# - name: Setup Gradle
# uses: gradle/gradle-build-action@v2
# - name: Build release APK
# run: ./gradlew assembleRelease
# - name: Upload APK artifact
# uses: actions/upload-artifact@v4
# with:
# name: app-release
# path: app/build/outputs/apk/release/*.apk
- name: Get upstream tag
run: echo "upstream_tag=${tag%%"-"*}" >> "$GITHUB_ENV"
- name: Get upstream changelog
env:
changelogs_folder: fastlane/metadata/android/en-US/changelogs
run: echo "changelog=${{ github.server_url }}/${{ github.repository }}/blob/$tag/$(find $changelogs_folder -name $(ls -vr $changelogs_folder | head -1))" >> "$GITHUB_ENV"
- name: Create release notes
env:
upstream_tag: ${{ env.upstream_tag }}
changelog: ${{ env.changelog }}
run: |
echo "release_notes=$([[ $tag =~ ^$upstream_tag(-1)?$ ]] && echo "This release merges latest NewPipe \`$upstream_tag\`.\n\nFor the complete list of changes see [CHANGELOG]($changelog).$([[ $tag != $upstream_tag ]] && echo "\n\nIf any changes specific to this fork were also made, they will be listed in the [Fork Changelog](#fork-changelog) below.\n\n### Fork Changelog")" || echo "This release only includes changes specific to this fork. Please view the [Fork Changelog](#fork-changelog) below for details.\n\n### Fork Changelog")" >> "$GITHUB_ENV"
echo "include_fork_changelog=$([[ $tag != $upstream_tag ]] && echo "true" || echo "false")" >> "$GITHUB_ENV"
- name: Create GitHub Release with APK
uses: ncipollo/release-action@v1
env:
release_notes: ${{ env.release_notes }}
include_fork_changelog: ${{ env.include_fork_changelog }}
with:
draft: true
tag: ${{ env.upstream_tag }}
name: TEST
artifacts: app/build/outputs/apk/release/*.apk
body: $release_notes
# body: "This release merges latest NewPipe `${{ env.upstream_tag }}`.\n\nFor the complete list of changes see [CHANGELOG](${{ env.changelog }})."
generateReleaseNotes: $include_fork_changelog
18 changes: 12 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,30 @@ android {
if (normalizedWorkingBranch.isEmpty() || workingBranch == "master" || workingBranch == "dev") {
// default values when branch name could not be determined or is master or dev
applicationIdSuffix ".debug"
resValue "string", "app_name", "NewPipe Debug"
resValue "string", "app_name", "NewPipe SponsorBlock Debug"
} else {
applicationIdSuffix ".debug." + normalizedWorkingBranch
resValue "string", "app_name", "NewPipe " + workingBranch
archivesBaseName = 'NewPipe_' + normalizedWorkingBranch
resValue "string", "app_name", "NewPipe SponsorBlock" + workingBranch
archivesBaseName = 'NewPipe_x_SponsorBlock' + normalizedWorkingBranch
}
}

release {
if (System.properties.containsKey('packageSuffix')) {
applicationIdSuffix System.getProperty('packageSuffix')
resValue "string", "app_name", "NewPipe " + System.getProperty('packageSuffix')
archivesBaseName = 'NewPipe_' + System.getProperty('packageSuffix')
resValue "string", "app_name", "NewPipe SponsorBlock" + System.getProperty('packageSuffix')
archivesBaseName = 'NewPipe_x_SponsorBlock' + System.getProperty('packageSuffix')
}
minifyEnabled true
shrinkResources false // disabled to fix F-Droid's reproducible build
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
archivesBaseName = 'app'
archivesBaseName = "NewPipe_x_SponsorBlock"
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
def forkRevision = 1
outputFileName = "${archivesBaseName}_v${variant.versionName}-${forkRevision}.apk"
}
}
}
}

Expand Down

0 comments on commit d8ae563

Please sign in to comment.