Skip to content

Commit 6397dfd

Browse files
authored
New workflow structure (#58)
* 2 differents workflow for nightly * Update release.yml
1 parent 183758e commit 6397dfd

File tree

3 files changed

+106
-158
lines changed

3 files changed

+106
-158
lines changed

.github/workflows/build_apk.yml

Lines changed: 0 additions & 89 deletions
This file was deleted.

.github/workflows/nightly.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Nightly Build
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
paths-ignore:
9+
- "*.md"
10+
11+
concurrency:
12+
group: ${{ github.ref }}-${{ github.workflow }}-nightly
13+
cancel-in-progress: true
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
lfs: true
24+
submodules: recursive
25+
26+
- name: Set up JDK 21
27+
uses: actions/setup-java@v4
28+
with:
29+
java-version: "21"
30+
distribution: "temurin"
31+
cache: gradle
32+
33+
# https://github.com/actions/cache/blob/main/examples.md#java---gradle
34+
- uses: actions/cache@v4
35+
with:
36+
path: |
37+
~/.gradle/caches
38+
~/.gradle/wrapper
39+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
40+
restore-keys: |
41+
${{ runner.os }}-gradle
42+
43+
- name: Build apk
44+
run: |
45+
./gradlew assembleNightly
46+
47+
mkdir -p packages
48+
# warning: do not use github.event syntax here
49+
# https://stackoverflow.com/questions/71458189/github-action-workflow-call-does-not-use-up-to-date-input-values
50+
mv app/build/outputs/apk/nightly/app-release.apk packages/gitnote-nightly.apk
51+
52+
- uses: actions/upload-artifact@v4
53+
with:
54+
name: releases
55+
path: packages/*
56+
if-no-files-found: error

.github/workflows/release.yml

Lines changed: 50 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
1-
name: Release
1+
name: Publish Release
22

33
on:
44
workflow_dispatch:
55
inputs:
6-
is_nightly:
7-
description: "Is nightly"
8-
required: false
9-
default: true
10-
type: boolean
116
version:
127
description: "App version"
13-
required: false
14-
default: ""
8+
required: true
159
type: string
16-
push:
17-
branches:
18-
- master
19-
paths-ignore:
20-
- "*.md"
10+
prerelease:
11+
description: "Is pre-release"
12+
type: boolean
13+
required: false
14+
default: false
2115

2216
concurrency:
2317
group: ${{ github.workflow }}-release
@@ -30,77 +24,64 @@ env:
3024
CARGO_TERM_COLOR: always
3125

3226
jobs:
33-
setup-env:
27+
release:
3428
runs-on: ubuntu-latest
3529
permissions:
3630
contents: write
37-
outputs:
38-
app_version: ${{ steps.set_outputs.outputs.app_version }}
39-
tag_name: ${{ steps.set_outputs.outputs.tag_name }}
40-
version_name: ${{ steps.set_outputs.outputs.version_name }}
41-
prerelease: ${{ steps.set_outputs.outputs.prerelease }}
42-
4331
steps:
4432
- uses: actions/checkout@v4
33+
with:
34+
lfs: true
35+
submodules: recursive
4536

46-
- if: ${{ (github.event.inputs.is_nightly == 'true') || (github.event.inputs.is_nightly == '') }}
47-
name: Setup options for a nightly release
48-
run: |
49-
echo "APP_VERSION=$(date +"%y.%m")" >> $GITHUB_ENV
50-
echo "TAG_NAME=nightly" >> $GITHUB_ENV
51-
echo "VERSION_NAME=nightly" >> $GITHUB_ENV
52-
echo "PRERELEASE=--prerelease" >> $GITHUB_ENV
53-
54-
- if: ${{ github.event.inputs.is_nightly == 'false' }}
55-
name: Setup options for a stable release
56-
run: |
57-
echo "APP_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
58-
echo "TAG_NAME=${{ github.event.inputs.version }}" >> $GITHUB_ENV
59-
echo "VERSION_NAME=${{ github.event.inputs.version }}" >> $GITHUB_ENV
37+
# - name: Build Libgit2
38+
# run: |
39+
# cd app/libgit2-android
40+
# ANDROID_API=34 ANDROID_ABI=arm64-v8a BUILD_ALL=1 INSTALL_NDK=1 ./build.sh
41+
# ANDROID_API=34 ANDROID_ABI=x86_64 BUILD_ALL=1 CLEAN=1 ./build.sh
6042

61-
- name: Set up outputs
62-
id: set_outputs
63-
run: |
64-
echo "app_version=${{ env.APP_VERSION }}" >> "$GITHUB_OUTPUT"
65-
echo "tag_name=${{ env.TAG_NAME }}" >> "$GITHUB_OUTPUT"
66-
echo "version_name=${{ env.VERSION_NAME }}" >> "$GITHUB_OUTPUT"
67-
echo "prerelease=${{ env.PRERELEASE }}" >> "$GITHUB_OUTPUT"
43+
- name: Set up JDK 21
44+
uses: actions/setup-java@v4
45+
with:
46+
java-version: "21"
47+
distribution: "temurin"
48+
cache: gradle
6849

69-
build-apk:
70-
needs: setup-env
71-
uses: ./.github/workflows/build_apk.yml
72-
secrets: inherit
73-
with:
74-
version: ${{ needs.setup-env.outputs.version_name }}
75-
is_nightly: ${{ inputs.is_nightly }}
50+
# https://github.com/actions/cache/blob/main/examples.md#java---gradle
51+
- uses: actions/cache@v4
52+
with:
53+
path: |
54+
~/.gradle/caches
55+
~/.gradle/wrapper
56+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
57+
restore-keys: |
58+
${{ runner.os }}-gradle
7659
77-
publish:
78-
needs: [build-apk, setup-env]
79-
runs-on: ubuntu-latest
80-
permissions:
81-
contents: write
60+
- name: Retrieve the secret and decode it to a file and Build apk
61+
env:
62+
KEY_BASE64: ${{ secrets.KEY_BASE64 }}
63+
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
64+
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
65+
STORE_PASSWORD: ${{ secrets.KEY_PASSWORD }}
66+
run: |
67+
echo $KEY_BASE64 | base64 --decode > app/key.jks
68+
./gradlew assembleRelease
8269
83-
steps:
84-
- uses: actions/checkout@v4
85-
with:
86-
# https://github.com/actions/checkout/issues/1471
87-
fetch-tags: false
70+
mkdir -p packages
71+
# warning: do not use github.event syntax here
72+
# https://stackoverflow.com/questions/71458189/github-action-workflow-call-does-not-use-up-to-date-input-values
73+
mv app/build/outputs/apk/release/app-release.apk packages/gitnote-release-${{ inputs.version }}.apk
8874
89-
# must be after checkout because it will remove artifacts
90-
- uses: actions/download-artifact@v4
91-
with:
92-
path: "packages"
75+
- if: ${{ (inputs.prerelease == 'true') }}
76+
run: |
77+
echo "PRERELEASE=--prerelease" >> $GITHUB_ENV
9378
9479
- name: Publish release
9580
run: |
96-
# delete previous nightly release
97-
gh release delete nightly --yes || true
98-
git push --delete origin nightly || true
99-
100-
git tag ${{ needs.setup-env.outputs.tag_name }}
81+
git tag ${{ inputs.version }}
10182
git push origin --tags
10283
10384
# https://cli.github.com/manual/gh_release_create
104-
gh release create ${{ needs.setup-env.outputs.tag_name }} --title "${{ needs.setup-env.outputs.version_name }}" \
105-
--verify-tag ${{ needs.setup-env.outputs.prerelease }} --generate-notes --target $GITHUB_SHA \
85+
gh release create ${{ inputs.version }} --title "${{ inputs.version }}" \
86+
--verify-tag ${{ env.PRERELEASE }} --generate-notes --target $GITHUB_SHA \
10687
./packages/*/*

0 commit comments

Comments
 (0)