aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/release.yml
blob: 10484521a9155c863406e1540b3a638d7b8f556d (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Release
on:
  push:
    tags:
      - 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
  build:
    name: Build release binaries
    runs-on: ubuntu-latest
    steps:
    - name: Checkout repository
      uses: actions/checkout@v2

    - name: Decrypt secrets
      run: release/signing-setup.sh "$ENCRYPT_KEY"
      env:
        ENCRYPT_KEY: ${{ secrets.ENCRYPT_KEY }}

    - name: Copy CI gradle.properties
      run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

    - name: Generate cache key
      run: ./.github/checksum.sh checksum.txt

    - name: Cache gradle modules
      uses: actions/cache@v2
      with:
        path: ~/.gradle/caches/modules-2
        key: ${{ runner.os }}-gradlemodules-${{ hashFiles('checksum.txt') }}
        restore-keys: |
          ${{ runner.os }}-gradlemodules-

    - name: Cache gradle jars
      uses: actions/cache@v2
      with:
        path: ~/.gradle/caches/jars-3
        key: ${{ runner.os }}-gradlejars-${{ hashFiles('checksum.txt') }}
        restore-keys: |
          ${{ runner.os }}-gradlejars-

    - name: Cache gradle build
      uses: actions/cache@v2
      with:
        path: ~/.gradle/caches/build-cache-1
        key: ${{ runner.os }}-gradlebuildcache-${{ hashFiles('checksum.txt') }}
        restore-keys: |
          ${{ runner.os }}-gradlebuildcache-

    - name: Download gradle dependencies
      run: ./gradlew dependencies

    - name: Build release binaries
      run: ./gradlew :app:assembleFreeRelease :app:assembleNonFreeRelease :app:bundleNonFreeRelease

    - name: Upload non-free release APK
      uses: actions/upload-artifact@v2
      with:
        name: APS Non-Free Release APK
        path: app/build/outputs/apk/nonFree/release/app-nonFree-release.apk

    - name: Upload non-free release Bundle
      uses: actions/upload-artifact@v2
      with:
        name: APS Non-Free Release Bundle
        path: app/build/outputs/bundle/nonFreeRelease/app-nonFree-release.aab

    - name: Upload free release APK
      uses: actions/upload-artifact@v2
      with:
        name: APS Free Release APK
        path: app/build/outputs/apk/free/release/app-free-release.apk

    - name: Clean secrets
      if: always()
      run: release/signing-cleanup.sh

  create_github_release:
    name: Create GitHub Release
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Get Non-Free Release APK
        uses: actions/download-artifact@v2
        with:
          name: APS Non-Free Release APK
          path: artifacts/nonFree

      - name: Get Non-Free Bundle
        uses: actions/download-artifact@v2
        with:
          name: APS Non-Free Release Bundle
          path: artifacts/nonFree

      - name: Get Free Release APK
        uses: actions/download-artifact@v2
        with:
          name: APS Free Release APK
          path: artifacts/free

      - name: Get Changelog Entry
        id: changelog_reader
        uses: mindsers/changelog-reader-action@v1.1.0
        with:
          version: ${{ github.ref }}
          path: ./CHANGELOG.md

      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: ${{ github.ref }}
          body: ${{ steps.changelog_reader.outputs.log_entry }}
          draft: true
          prerelease: false

      - name: Get the version
        id: get_version
        run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}

      - name: Upload Non-Free Release Apk
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: ./artifacts/nonFree/app-nonFree-release.apk
          asset_name: APS-nonFree_${{ steps.get_version.outputs.VERSION }}.apk
          asset_content_type: application/vnd.android.package-archive

      - name: Upload Non-Free Release Bundle
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: ./artifacts/nonFree/app-nonFree-release.aab
          asset_name: APS-nonFree_${{ steps.get_version.outputs.VERSION }}.aab
          asset_content_type: application/octet-stream

      - name: Upload Free Release Apk
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: ./artifacts/free/app-free-release.apk
          asset_name: APS-free_${{ steps.get_version.outputs.VERSION }}.apk
          asset_content_type: application/vnd.android.package-archive