-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CI: separate fastlane and build code...WIP #114
Draft
0xbrayo
wants to merge
6
commits into
ActivityWatch:master
Choose a base branch
from
0xbrayo:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a7b04d6
chore: add 'sh' to README.md
0xbrayo b93ed9e
feat: update deprecated magick command
0xbrayo e6b3c51
ci: separate fastlane code from build code
0xbrayo d54aed0
ci: add release-gh to build-only.yml
0xbrayo 53ed4a3
chore: replace the default android.jks.age
0xbrayo 854877e
ci:set rust version to 1.79.0
0xbrayo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,234 @@ | ||
name: "Build only" | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
tags: | ||
- v* | ||
pull_request: | ||
branches: [ master ] | ||
|
||
|
||
env: | ||
NDK_VERSION: '25.2.9519653' | ||
NODE_VERSION: '16' | ||
JAVA_VERSION: '17' | ||
|
||
jobs: | ||
build-rust: | ||
name: Build aw-server-rust | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: 'recursive' | ||
- name: Set RELEASE | ||
run: | | ||
echo "RELEASE=${{ startsWith(github.ref_name, 'v') }}" >> $GITHUB_ENV | ||
|
||
- name: Cache JNI libs | ||
uses: actions/cache@v3 | ||
id: cache-jniLibs | ||
env: | ||
cache-name: jniLibs | ||
with: | ||
path: mobile/src/main/jniLibs/ | ||
key: ${{ env.cache-name }}-release-${{ env.RELEASE }}-ndk-${{ env.NDK_VERSION }}-${{ hashFiles('.git/modules/aw-server-rust/HEAD') }} | ||
|
||
- name: Display structure of downloaded files | ||
if: steps.cache-jniLibs.outputs.cache-hit == 'true' | ||
run: | | ||
pushd mobile/src/main/jniLibs && ls -R && popd | ||
|
||
# Android SDK & NDK | ||
- name: Set up Android SDK | ||
if: steps.cache-jniLibs.outputs.cache-hit != 'true' | ||
uses: android-actions/setup-android@v2 | ||
- name: Set up Android NDK | ||
if: steps.cache-jniLibs.outputs.cache-hit != 'true' | ||
run: | | ||
sdkmanager "ndk;${{ env.NDK_VERSION }}" | ||
ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ env.NDK_VERSION }}" | ||
ls $ANDROID_NDK_HOME | ||
echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV | ||
|
||
# Rust | ||
- name: Set up Rust | ||
id: toolchain | ||
uses: dtolnay/rust-toolchain@1.79.0 | ||
if: steps.cache-jniLibs.outputs.cache-hit != 'true' | ||
|
||
- name: Set up Rust toolchain for Android NDK | ||
if: steps.cache-jniLibs.outputs.cache-hit != 'true' | ||
run: | | ||
./aw-server-rust/install-ndk.sh | ||
|
||
- name: Cache cargo build | ||
uses: actions/cache@v3 | ||
if: steps.cache-jniLibs.outputs.cache-hit != 'true' | ||
env: | ||
cache-name: cargo-build-target | ||
with: | ||
path: aw-server-rust/target | ||
# key needs to contain cachekey due to https://github.com/ActivityWatch/aw-server-rust/issues/180 | ||
key: ${{ env.cache-name }}-${{ runner.os }}-release-${{ env.RELEASE }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('**/Cargo.lock') }} | ||
restore-keys: | | ||
${{ env.cache-name }}-${{ runner.os }}-release-${{ env.RELEASE }}-${{ steps.toolchain.outputs.cachekey }}- | ||
|
||
- name: Build aw-server-rust | ||
if: steps.cache-jniLibs.outputs.cache-hit != 'true' | ||
run: | | ||
make aw-server-rust | ||
|
||
- name: Check that jniLibs present | ||
run: | | ||
test -e mobile/src/main/jniLibs/x86_64/libaw_server.so | ||
|
||
# This needs to be a seperate job since fastlane update_version, | ||
# fails if run concurrently (such as in build apk/aab matrix), | ||
# thus we need to run it once and and reuse the results. | ||
# https://github.com/fastlane/fastlane/issues/13689#issuecomment-439217502 | ||
get-versionCode: | ||
name: Get latest versionCode | ||
runs-on: ubuntu-latest | ||
outputs: | ||
versionCode: ${{ steps.versionCode.outputs.versionCode }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: 'recursive' | ||
|
||
- name: Output versionCode | ||
id: versionCode | ||
run: | | ||
cat mobile/build.gradle | grep versionCode | sed 's/.*\s\([0-9]*\)$/versionCode=\1/' >> "$GITHUB_OUTPUT" | ||
|
||
build-apk: | ||
name: Build ${{ matrix.type }} | ||
runs-on: ubuntu-20.04 | ||
needs: [build-rust, get-versionCode] | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
type: ['apk', 'aab'] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: 'recursive' | ||
|
||
- uses: ActivityWatch/check-version-format-action@v2 | ||
id: version | ||
with: | ||
prefix: 'v' | ||
|
||
- name: Echo version | ||
run: | | ||
echo "${{ steps.version.outputs.full }} (stable: ${{ steps.version.outputs.is_stable }})" | ||
|
||
- name: Set RELEASE | ||
run: | | ||
# Build in release mode if on a tag/release (longer build times) | ||
echo "RELEASE=${{ startsWith(github.ref_name, 'v') }}" >> $GITHUB_ENV | ||
|
||
- name: Set up JDK | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: ${{ env.JAVA_VERSION }} | ||
|
||
# Android SDK & NDK | ||
- name: Set up Android SDK | ||
uses: android-actions/setup-android@v2 | ||
- name: Set up Android NDK | ||
run: | | ||
sdkmanager "ndk;${{ env.NDK_VERSION }}" | ||
ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ env.NDK_VERSION }}" | ||
ls $ANDROID_NDK_HOME | ||
echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV | ||
|
||
# Restores jniLibs from cache | ||
# `actions/cache/restore` only restores, without saving back in a post-hook | ||
- uses: actions/cache/restore@v3 | ||
id: cache-jniLibs | ||
env: | ||
cache-name: jniLibs | ||
with: | ||
path: mobile/src/main/jniLibs/ | ||
key: ${{ env.cache-name }}-release-${{ env.RELEASE }}-ndk-${{ env.NDK_VERSION }}-${{ hashFiles('.git/modules/aw-server-rust/HEAD') }} | ||
fail-on-cache-miss: true | ||
|
||
- name: Check that jniLibs present | ||
run: | | ||
test -e mobile/src/main/jniLibs/x86_64/libaw_server.so | ||
|
||
- name: Set versionName | ||
if: startsWith(github.ref, 'refs/tags/v') # only on runs triggered from tag | ||
run: | | ||
# Sets versionName, tail used to skip "v" at start of tag name | ||
SHORT_VERSION=$(echo "${{ github.ref_name }}" | tail -c +2 -) | ||
sed -i "s/versionName \".*\"/versionName \"$SHORT_VERSION\"/g" \ | ||
mobile/build.gradle | ||
|
||
- name: Set versionCode | ||
run: | | ||
# Sets versionCode | ||
sed -i "s/versionCode .*/versionCode ${{needs.get-versionCode.outputs.versionCode}}/" \ | ||
mobile/build.gradle | ||
|
||
- uses: adnsio/setup-age-action@v1.2.0 | ||
- name: Load Android secrets | ||
if: env.KEY_ANDROID_JKS != null | ||
env: | ||
KEY_ANDROID_JKS: ${{ secrets.KEY_ANDROID_JKS }} | ||
run: | | ||
printf "$KEY_ANDROID_JKS" > android.jks.key | ||
cat android.jks.age | age -d -i android.jks.key -o android.jks | ||
rm android.jks.key | ||
|
||
- name: Assemble | ||
env: | ||
JKS_STOREPASS: ${{ secrets.KEY_ANDROID_JKS_STOREPASS }} | ||
JKS_KEYPASS: ${{ secrets.KEY_ANDROID_JKS_KEYPASS }} | ||
run: | | ||
make dist/aw-android.${{ matrix.type }} | ||
|
||
- name: Upload | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: aw-android | ||
path: dist/aw-android*.${{ matrix.type }} | ||
|
||
release-gh: | ||
needs: [build-apk] | ||
if: startsWith(github.ref, 'refs/tags/v') # only on runs triggered from tag | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
# Will download all artifacts to path | ||
- name: Download release APK & AAB | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: aw-android | ||
path: dist | ||
|
||
- name: Display structure of downloaded files | ||
working-directory: dist | ||
run: ls -R | ||
|
||
# detect if version tag is stable/beta | ||
- uses: nowsprinting/check-version-format-action@v2 | ||
id: version | ||
with: | ||
prefix: 'v' | ||
|
||
# create a release | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
draft: true | ||
prerelease: ${{ !(steps.version.outputs.is_stable == 'true') }} # must compare to true, since boolean outputs are actually just strings, and "false" is truthy since it's not empty: https://github.com/actions/runner/issues/1483#issuecomment-994986996 | ||
files: | | ||
dist/*.apk | ||
dist/*.aab | ||
# body_path: dist/release_notes/release_notes.md |
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
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
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider upgrading to the latest version of
actions/setup-java
to benefit from new features and improvements: