|
| 1 | +name: Build and Publish Release |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - "v*.*.*" |
| 6 | + |
| 7 | +env: |
| 8 | + PROJECT_NAME: chat-frontend |
| 9 | + |
| 10 | +jobs: |
| 11 | + build-desktop: |
| 12 | + name: Build Desktop (${{ matrix.os }}) |
| 13 | + runs-on: ${{ matrix.os }} |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + include: |
| 17 | + - target: x86_64-unknown-linux-gnu |
| 18 | + os: ubuntu-latest |
| 19 | + name: x86_64-unknown-linux-gnu.tar.gz |
| 20 | + - target: aarch-64-apple-darwin |
| 21 | + os: macOS-latest |
| 22 | + name: aarch-64-apple-darwin.tar.gz |
| 23 | + - target: x86_64-pc-windows-msvc |
| 24 | + os: windows-latest |
| 25 | + name: x86_64-pc-windows-msvc.zip |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: "Setup | Checkout" |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: "Setup | JDK 17" |
| 32 | + uses: actions/setup-java@v4 |
| 33 | + with: |
| 34 | + java-version: '17' |
| 35 | + distribution: 'jetbrains' |
| 36 | + cache: 'gradle' |
| 37 | + |
| 38 | + - name: "Setup | Gradle" |
| 39 | + uses: gradle/actions/setup-gradle@v4 |
| 40 | + |
| 41 | + - name: "Setup | Extract tag name" |
| 42 | + shell: bash |
| 43 | + id: extract_tag |
| 44 | + run: | |
| 45 | + tag=$(echo ${GITHUB_REF#refs/tags/}) |
| 46 | + echo "tag=$tag" >> $GITHUB_OUTPUT |
| 47 | +
|
| 48 | + - name: "Build | Desktop Application" |
| 49 | + run: ./gradlew :composeApp:createReleaseDistributable |
| 50 | + |
| 51 | + - name: "Package | Desktop Application (Windows)" |
| 52 | + if: matrix.os == 'windows-latest' |
| 53 | + shell: bash |
| 54 | + run: | |
| 55 | + cd composeApp/build/compose/binaries/main-release/app |
| 56 | + mkdir -p ../artifacts |
| 57 | + 7z a ../artifacts/${{ env.PROJECT_NAME }}-${{ steps.extract_tag.outputs.tag }}-${{ matrix.name }}.zip . |
| 58 | + cd - |
| 59 | +
|
| 60 | + - name: "Package | Desktop Application (-nix)" |
| 61 | + if: matrix.os != 'windows-latest' |
| 62 | + shell: bash |
| 63 | + run: | |
| 64 | + cd composeApp/build/compose/binaries/main-release/app |
| 65 | + mkdir -p ../artifacts |
| 66 | + tar czvf ../artifacts/${{ env.PROJECT_NAME }}-${{ steps.extract_tag.outputs.tag }}-${{ matrix.name }}.tar.gz . |
| 67 | + cd - |
| 68 | +
|
| 69 | + - name: Post Setup | Upload artifacts |
| 70 | + uses: actions/upload-artifact@v4 |
| 71 | + with: |
| 72 | + name: ${{ env.PROJECT_NAME }}-${{ steps.extract_tag.outputs.tag }}-${{ matrix.name }} |
| 73 | + path: composeApp/build/compose/binaries/main-release/artifacts |
| 74 | + overwrite: true |
| 75 | + |
| 76 | + build-android: |
| 77 | + name: Build Android |
| 78 | + runs-on: ubuntu-latest |
| 79 | + |
| 80 | + steps: |
| 81 | + - name: Checkout Code |
| 82 | + uses: actions/checkout@v4 |
| 83 | + |
| 84 | + - name: Set up JDK 17 |
| 85 | + uses: actions/setup-java@v4 |
| 86 | + with: |
| 87 | + java-version: '17' |
| 88 | + distribution: 'jetbrains' |
| 89 | + cache: 'gradle' |
| 90 | + |
| 91 | + - name: Setup Gradle |
| 92 | + uses: gradle/actions/setup-gradle@v4 |
| 93 | + |
| 94 | + - name: "Setup | Extract tag name" |
| 95 | + shell: bash |
| 96 | + id: extract_tag |
| 97 | + run: | |
| 98 | + tag=$(echo ${GITHUB_REF#refs/tags/}) |
| 99 | + echo "tag=$tag" >> $GITHUB_OUTPUT |
| 100 | +
|
| 101 | + - name: Build | Android APK |
| 102 | + run: ./gradlew :composeApp:assembleRelease |
| 103 | + |
| 104 | + - name: Package | Android APK |
| 105 | + shell: bash |
| 106 | + run: | |
| 107 | + cd composeApp/build/outputs/apk/release |
| 108 | + mkdir artifacts |
| 109 | + mv composeApp-release.apk artifacts/${{ env.PROJECT_NAME }}-${{ steps.extract_tag.outputs.tag }}.apk |
| 110 | + cd - |
| 111 | +
|
| 112 | + - name: Post Setup | Upload artifacts |
| 113 | + uses: actions/upload-artifact@v4 |
| 114 | + with: |
| 115 | + name: ${{ env.PROJECT_NAME }}-${{ steps.extract_tag.outputs.tag }}-android |
| 116 | + path: composeApp/build/outputs/apk/release/artifacts |
| 117 | + overwrite: true |
| 118 | + |
| 119 | + |
| 120 | + github_release: |
| 121 | + name: Create GitHub Release |
| 122 | + needs: [build-desktop, build-android] |
| 123 | + runs-on: ubuntu-latest |
| 124 | + steps: |
| 125 | + - name: Setup | Checkout |
| 126 | + uses: actions/checkout@v4 |
| 127 | + with: |
| 128 | + fetch-depth: 0 |
| 129 | + |
| 130 | + - name: Setup | Artifacts |
| 131 | + uses: actions/download-artifact@v4 |
| 132 | + with: |
| 133 | + path: artifacts |
| 134 | + merge-multiple: true |
| 135 | + |
| 136 | + - name: Setup | Extract version |
| 137 | + shell: bash |
| 138 | + id: extract_version |
| 139 | + run: | |
| 140 | + version=$(echo ${GITHUB_REF#refs/tags/v}) |
| 141 | + echo "version=$version" >> $GITHUB_OUTPUT |
| 142 | +
|
| 143 | + - name: Build | Publish |
| 144 | + uses: softprops/action-gh-release@v2 |
| 145 | + with: |
| 146 | + files: artifacts/* |
| 147 | + env: |
| 148 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments