|
| 1 | +name: 'publish' |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*' # Only run on tag pushes. |
| 7 | + |
| 8 | +env: |
| 9 | + APP_NAME: "Super-Note" |
| 10 | + |
| 11 | +jobs: |
| 12 | + changelog: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Build changelog |
| 19 | + id: build_changelog |
| 20 | + run: | |
| 21 | + PREV_TAG=$(git tag --list v* | tail -n2 | head -n1) |
| 22 | + echo "changelog=$(git log $PREV_TAG...${{ github.ref_name }} --pretty=format:"- %s")" >> $GITHUB_OUTPUT |
| 23 | + outputs: |
| 24 | + changelog: ${{ steps.build_changelog.outputs.changelog }} |
| 25 | + |
| 26 | + release: |
| 27 | + environment: production |
| 28 | + permissions: |
| 29 | + contents: write |
| 30 | + strategy: |
| 31 | + fail-fast: false |
| 32 | + matrix: |
| 33 | + include: |
| 34 | + # Windows Desktop Build |
| 35 | + - os: windows-latest |
| 36 | + rust-target: '' |
| 37 | + tauri-args: '' |
| 38 | + type: 'desktop' |
| 39 | + upload-updater: true |
| 40 | + # macOS ARM Build |
| 41 | + - os: macos-latest |
| 42 | + rust-target: 'aarch64-apple-darwin' |
| 43 | + tauri-args: '--target aarch64-apple-darwin' |
| 44 | + type: 'desktop' |
| 45 | + # macOS Intel Build |
| 46 | + - os: macos-latest |
| 47 | + rust-target: 'x86_64-apple-darwin' |
| 48 | + tauri-args: '--target x86_64-apple-darwin' |
| 49 | + type: 'desktop' |
| 50 | + # Linux Desktop Build |
| 51 | + - os: ubuntu-22.04 |
| 52 | + rust-target: '' |
| 53 | + tauri-args: '--bundles deb,rpm,updater' |
| 54 | + type: 'desktop' |
| 55 | + # Android Build |
| 56 | + - os: ubuntu-latest |
| 57 | + rust-target: 'aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android' |
| 58 | + tauri-args: '' |
| 59 | + type: 'android' |
| 60 | + |
| 61 | + runs-on: ${{ matrix.os }} |
| 62 | + needs: [changelog] |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v4 |
| 65 | + |
| 66 | + - name: setup Android signing |
| 67 | + if: matrix.type == 'android' |
| 68 | + run: | |
| 69 | + cd src-tauri/gen/android |
| 70 | + echo "keyAlias=${{ secrets.ANDROID_RELEASE_KEY }}" > keystore.properties |
| 71 | + echo "password=${{ secrets.ANDROID_RELEASE_PASSWORD }}" >> keystore.properties |
| 72 | + base64 -d <<< "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" > $RUNNER_TEMP/uploadkeystore.jks |
| 73 | + echo "storeFile=$RUNNER_TEMP/uploadkeystore.jks" >> keystore.properties |
| 74 | +
|
| 75 | + - uses: pnpm/action-setup@v4 |
| 76 | + with: |
| 77 | + version: 8 |
| 78 | + |
| 79 | + - name: Setup Java |
| 80 | + if: matrix.type == 'android' |
| 81 | + uses: actions/setup-java@v4 |
| 82 | + with: |
| 83 | + distribution: 'temurin' |
| 84 | + java-version: '17' |
| 85 | + |
| 86 | + - name: Setup Android SDK |
| 87 | + if: matrix.type == 'android' |
| 88 | + uses: android-actions/setup-android@v3 |
| 89 | + |
| 90 | + - name: Install NDK |
| 91 | + if: matrix.type == 'android' |
| 92 | + run: sdkmanager "ndk;27.0.11902837" |
| 93 | + |
| 94 | + - name: setup node |
| 95 | + uses: actions/setup-node@v4 |
| 96 | + with: |
| 97 | + node-version: lts/* |
| 98 | + |
| 99 | + - name: install Bun (Desktop only) |
| 100 | + if: matrix.type == 'desktop' |
| 101 | + uses: oven-sh/setup-bun@v2 |
| 102 | + with: |
| 103 | + bun-version: latest |
| 104 | + |
| 105 | + - name: setup Python (Desktop only) |
| 106 | + if: matrix.type == 'desktop' |
| 107 | + uses: actions/setup-python@v5 |
| 108 | + with: |
| 109 | + python-version: '3.x' |
| 110 | + |
| 111 | + - name: install PyInstaller (Desktop only) |
| 112 | + if: matrix.type == 'desktop' |
| 113 | + run: pip install pyinstaller |
| 114 | + |
| 115 | + - name: install Rust stable |
| 116 | + uses: dtolnay/rust-toolchain@stable |
| 117 | + with: |
| 118 | + targets: ${{ matrix.rust-target }} |
| 119 | + |
| 120 | + - name: install dependencies (ubuntu only) |
| 121 | + if: matrix.os == 'ubuntu-22.04' |
| 122 | + run: | |
| 123 | + sudo apt-get update |
| 124 | + sudo apt-get install -y build-essential libssl-dev libgtk-3-dev libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev patchelf libfuse2 libjavascriptcoregtk-4.1-dev libsoup-3.0-dev file |
| 125 | +
|
| 126 | + - name: install frontend dependencies |
| 127 | + run: pnpm install |
| 128 | + |
| 129 | + - name: Build Tauri app |
| 130 | + if: matrix.type == 'desktop' |
| 131 | + uses: tauri-apps/tauri-action@v0 |
| 132 | + env: |
| 133 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 134 | + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} |
| 135 | + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} |
| 136 | + # Compatibility with some versions of the action |
| 137 | + TAURI_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} |
| 138 | + TAURI_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} |
| 139 | + APPIMAGE_EXTRACT_AND_RUN: 1 |
| 140 | + with: |
| 141 | + tagName: ${{ github.ref_name }} |
| 142 | + releaseName: "${{ env.APP_NAME }} ${{ github.ref_name }}" |
| 143 | + releaseBody: | |
| 144 | + ${{needs.changelog.outputs.changelog}} |
| 145 | + See the assets to download this version and install. |
| 146 | + releaseDraft: false |
| 147 | + prerelease: false |
| 148 | + args: ${{ matrix.tauri-args }} |
| 149 | + includeUpdaterJson: ${{ matrix.upload-updater || false }} |
| 150 | + |
| 151 | + - name: Extract version from tag |
| 152 | + if: matrix.type == 'android' |
| 153 | + id: package-version |
| 154 | + run: echo "current-version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT |
| 155 | + |
| 156 | + - name: Build app bundle |
| 157 | + if: matrix.type == 'android' |
| 158 | + run: pnpm tauri android build -v |
| 159 | + env: |
| 160 | + NDK_HOME: ${{ env.ANDROID_HOME }}/ndk/27.0.11902837 |
| 161 | + |
| 162 | + - name: Rename APK file |
| 163 | + if: matrix.type == 'android' |
| 164 | + run: | |
| 165 | + # Create a guaranteed safe destination folder |
| 166 | + mkdir -p ./src-tauri/gen/android/app/build/outputs/apk/final_release |
| 167 | + # Find any APK generated and move it there with the new name |
| 168 | + find ./src-tauri/gen/android/app/build/outputs/apk/ -type f -name "*.apk" -exec mv {} ./src-tauri/gen/android/app/build/outputs/apk/final_release/${{ env.APP_NAME }}-${{ steps.package-version.outputs.current-version }}.apk \; |
| 169 | + |
| 170 | + - name: Build Android App Bundle |
| 171 | + if: matrix.type == 'android' |
| 172 | + uses: softprops/action-gh-release@v1 |
| 173 | + with: |
| 174 | + tag_name: ${{ github.ref_name }} |
| 175 | + name: "${{ env.APP_NAME }} ${{ github.ref_name }}" |
| 176 | + draft: false |
| 177 | + prerelease: false |
| 178 | + files: | |
| 179 | + ./src-tauri/gen/android/app/build/outputs/apk/final_release/${{ env.APP_NAME }}-${{ steps.package-version.outputs.current-version }}.apk |
0 commit comments