Skip to content

Commit

Permalink
186 improve release ci (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
StaehliJ authored Jul 26, 2023
1 parent bf00809 commit 6d43e26
Show file tree
Hide file tree
Showing 20 changed files with 225 additions and 323 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ jobs:
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- uses: reviewdog/action-setup@v1
- name: Run android linter
uses: gradle/gradle-build-action@v2
with:
arguments: lint
arguments: lintProdDebug
- name: review linter
uses: dvdandroid/action-android-lint@master
with:
Expand All @@ -46,6 +47,7 @@ jobs:
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- uses: reviewdog/action-setup@v1
- name: review detekt
uses: alaegin/[email protected]
Expand Down Expand Up @@ -75,7 +77,8 @@ jobs:
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- name: Run android local unit test
uses: gradle/gradle-build-action@v2
with:
arguments: testDebug
arguments: testProdDebug
83 changes: 83 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Run nightly every nights at midnight or when triggered manually
# https://github.com/orgs/community/discussions/27128
name: Publish demo nightly

on:
workflow_dispatch:
inputs:
version_name:
description: 'version name as xx.yy.zz-Optional'
required: true
type: string
schedule:
- cron: '0 0 * * 1,5'

jobs:
check_date:
runs-on: ubuntu-latest
name: Check latest commit
outputs:
should_run: ${{ steps.should_run.outputs.should_run }}

steps:
- uses: actions/checkout@v3
- name: print latest_commit
run: echo ${{ github.sha }}
- id: should_run
continue-on-error: true
name: check latest commit is less than a day
if: ${{ github.event_name == 'schedule' }}
run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "should_run=false" >> "$GITHUB_OUTPUT"

Build-nightly:
needs: check_date
if: ${{ needs.check_date.outputs.should_run != 'false' }}
runs-on: ubuntu-latest
env:
DEMO_KEY_PASSWORD: ${{ secrets.DEMO_KEY_PASSWORD }}
USERNAME: ${{ github.actor }}
GITHUB_TOKEN: ${{ github.token }}

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Required due to the way Git works, without it this action won't be able to find any or the correct tags
- name: VERSION_NAME from inputs
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo "VERSION_NAME=${{ inputs.version_name }}" >> "$GITHUB_ENV"
- name: Find latest tag
if: ${{ github.event_name != 'workflow_dispatch' }}
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: 0.0.1-alpha01 # Optional fallback tag to use when no tag can be found
- name: Setup VERSION_NAME from latest git tag
if: ${{ github.event_name != 'workflow_dispatch' }}
run: |
echo "VERSION_NAME=${{ steps.previoustag.outputs.tag }}" >> "$GITHUB_ENV"
- name: Print VersionName
run: |
echo "Version name is ${{ env.VERSION_NAME }}"
echo "ref ${GITHUB_REF}"
echo "refname ${GITHUB_REF_NAME}"
echo "refname ${GITHUB_REF_TYPE}"
echo "CI ${{ env.CI }}"
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- name: Build with Gradle
uses: gradle/[email protected]
with:
arguments: assembleNightlyRelease
- name: upload artifact to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action@v1
with:
appId: ${{ secrets.NIGHTLY_APP_ID }}
serviceCredentialsFileContent: ${{ secrets.FIREBASE_CREDENTIAL_FILE_CONTENT }}
groups: ${{ secrets.NIGHTLY_GROUPS }}
file: pillarbox-demo/build/outputs/apk/nightly/release/pillarbox-demo-nightly-release.apk

50 changes: 0 additions & 50 deletions .github/workflows/publish-demo.yml

This file was deleted.

73 changes: 0 additions & 73 deletions .github/workflows/publish-library.yml

This file was deleted.

39 changes: 0 additions & 39 deletions .github/workflows/publish-nightly.yml

This file was deleted.

72 changes: 56 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,59 @@
name: Release Pillarbox
on:
workflow_dispatch:

push:
# Pattern matched against refs/tags
tags:
- '[0-9]+.[0-9].[0-9]'
- '[0-9]+.[0-9].[0-9]-[0-9a-zA-Z]+'
jobs:
PublishRelease:
name: Build and upload library to Github packages
uses: ./.github/workflows/publish-library.yml
with:
isSnapshot: false
secrets: inherit
UploadDemo:
name: Upload Demo to Firebase AppDistribution
uses: ./.github/workflows/publish-demo.yml
secrets:
KEY_PASSWORD: ${{ secrets.DEMO_KEY_PASSWORD }}
FIREBASE_CREDENTIAL_FILE_CONTENT: ${{ secrets.FIREBASE_CREDENTIAL_FILE_CONTENT }}
FIREBASE_GROUP: ${{ secrets.RELEASE_GROUPS }}
FIREBASE_APP_ID: ${{ secrets.RELEASE_APP_ID }}
build:
runs-on: ubuntu-latest
env:
DEMO_KEY_PASSWORD: ${{ secrets.DEMO_KEY_PASSWORD }}
USERNAME: ${{ github.actor }}
GITHUB_TOKEN: ${{ github.token }}
VERSION_NAME: ${{ github.ref_name }}

steps:
- uses: actions/checkout@v3
- name: Check if pre release tag
id: check-tag
run: |
if [[ "${GITHUB_REF_NAME}" =~ [0-9]+.[0-9].[0-9]-[0-9a-zA-Z]+ ]]; then
echo "prerelease=true" >> $GITHUB_OUTPUT
fi
- name: Print release tag
run: |
echo "tag = ${GITHUB_REF_NAME}"
echo "version_name = ${VERSION_NAME}"
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
# the publishing section of your build.gradle
- name: Publish to GitHub Packages
uses: gradle/[email protected]
with:
arguments: publish
- name: Build with Gradle
uses: gradle/[email protected]
with:
arguments: assembleProdRelease
- name: upload artifact to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action@v1
with:
appId: ${{ secrets.RELEASE_APP_ID }}
serviceCredentialsFileContent: ${{ secrets.FIREBASE_CREDENTIAL_FILE_CONTENT }}
groups: ${{ secrets.RELEASE_GROUPS }}
file: pillarbox-demo/build/outputs/apk/prod/release/pillarbox-demo-prod-release.apk
- name: Create Github release
uses: ncipollo/release-action@v1
with:
draft: true
prerelease: steps.check-tag.outputs.prerelease == 'true'
skipIfReleaseExists: true
generateReleaseNotes: true
8 changes: 3 additions & 5 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ jobs:
distribution: temurin
java-version: 17
cache: 'gradle'
- name: Setup and execute Gradle 'buildDebug' task
- name: Gradle cache
uses: gradle/gradle-build-action@v2
with:
arguments: buildDebug
- name: AVD cache
uses: actions/cache@v3
id: avd-cache
Expand All @@ -42,15 +40,15 @@ jobs:
key: avd-26
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
uses: reactivecircus/android-emulator-runner@v2.28.0
with:
api-level: 26
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: run tests
uses: reactivecircus/android-emulator-runner@v2
uses: reactivecircus/android-emulator-runner@v2.28.0
with:
api-level: 26
force-avd-creation: false
Expand Down
Loading

0 comments on commit 6d43e26

Please sign in to comment.