|
1 |
| -name: Release |
| 1 | +name: Publish Release |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | workflow_dispatch:
|
5 | 5 | inputs:
|
6 |
| - is_nightly: |
7 |
| - description: "Is nightly" |
8 |
| - required: false |
9 |
| - default: true |
10 |
| - type: boolean |
11 | 6 | version:
|
12 | 7 | description: "App version"
|
13 |
| - required: false |
14 |
| - default: "" |
| 8 | + required: true |
15 | 9 | 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 |
21 | 15 |
|
22 | 16 | concurrency:
|
23 | 17 | group: ${{ github.workflow }}-release
|
|
30 | 24 | CARGO_TERM_COLOR: always
|
31 | 25 |
|
32 | 26 | jobs:
|
33 |
| - setup-env: |
| 27 | + release: |
34 | 28 | runs-on: ubuntu-latest
|
35 | 29 | permissions:
|
36 | 30 | 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 |
| - |
43 | 31 | steps:
|
44 | 32 | - uses: actions/checkout@v4
|
| 33 | + with: |
| 34 | + lfs: true |
| 35 | + submodules: recursive |
45 | 36 |
|
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 |
60 | 42 |
|
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 |
68 | 49 |
|
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 |
76 | 59 |
|
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 |
82 | 69 |
|
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 |
88 | 74 |
|
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 |
93 | 78 |
|
94 | 79 | - name: Publish release
|
95 | 80 | 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 }} |
101 | 82 | git push origin --tags
|
102 | 83 |
|
103 | 84 | # 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 \ |
106 | 87 | ./packages/*/*
|
0 commit comments