|
| 1 | +# This workflow is provided via the organization template repository |
| 2 | +# |
| 3 | +# https://github.com/nextcloud/.github |
| 4 | +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization |
| 5 | +# |
| 6 | +# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors |
| 7 | +# SPDX-License-Identifier: MIT |
| 8 | + |
| 9 | +name: Build and publish app release |
| 10 | + |
| 11 | +on: |
| 12 | + release: |
| 13 | + types: [published] |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: write |
| 17 | + |
| 18 | +jobs: |
| 19 | + build_and_publish: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + |
| 22 | + # Only allowed to be run on nextcloud-releases repositories |
| 23 | + if: ${{ github.repository_owner == 'nextcloud-releases' }} |
| 24 | + |
| 25 | + steps: |
| 26 | + - uses: cachix/install-nix-action@fc6e360bedc9ee72d75e701397f0bb30dce77568 # v31.5.2 |
| 27 | + - uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16 |
| 28 | + with: |
| 29 | + name: notify-push |
| 30 | + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' |
| 31 | + |
| 32 | + - name: Check actor permission |
| 33 | + uses: skjnldsv/check-actor-permission@69e92a3c4711150929bca9fcf34448c5bf5526e7 # v3.0 |
| 34 | + with: |
| 35 | + require: write |
| 36 | + |
| 37 | + - name: Set app env |
| 38 | + run: | |
| 39 | + # Split and keep last |
| 40 | + echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV |
| 41 | + echo "APP_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV |
| 42 | +
|
| 43 | + - name: Checkout |
| 44 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 45 | + with: |
| 46 | + persist-credentials: false |
| 47 | + path: ${{ env.APP_NAME }} |
| 48 | + fetch-depth: 0 |
| 49 | + |
| 50 | + - name: Get app version number |
| 51 | + id: app-version |
| 52 | + uses: skjnldsv/xpath-action@f5b036e9d973f42c86324833fd00be90665fbf77 # v1.0.0 |
| 53 | + with: |
| 54 | + filename: ${{ env.APP_NAME }}/appinfo/info.xml |
| 55 | + expression: "//info//version/text()" |
| 56 | + |
| 57 | + - name: Validate app version against tag |
| 58 | + run: | |
| 59 | + [ "${{ env.APP_VERSION }}" = "v${{ fromJSON(steps.app-version.outputs.result).version }}" ] |
| 60 | +
|
| 61 | + - name: Get appinfo data |
| 62 | + id: appinfo |
| 63 | + uses: skjnldsv/xpath-action@f5b036e9d973f42c86324833fd00be90665fbf77 # v1.0.0 |
| 64 | + with: |
| 65 | + filename: ${{ env.APP_NAME }}/appinfo/info.xml |
| 66 | + expression: "//info//dependencies//nextcloud/@min-version" |
| 67 | + |
| 68 | + - name: Read package.json node and npm engines version |
| 69 | + uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3 |
| 70 | + id: versions |
| 71 | + # Continue if no package.json |
| 72 | + continue-on-error: true |
| 73 | + with: |
| 74 | + path: ${{ env.APP_NAME }} |
| 75 | + fallbackNode: '^20' |
| 76 | + fallbackNpm: '^10' |
| 77 | + |
| 78 | + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} |
| 79 | + # Skip if no package.json |
| 80 | + if: ${{ steps.versions.outputs.nodeVersion }} |
| 81 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
| 82 | + with: |
| 83 | + node-version: ${{ steps.versions.outputs.nodeVersion }} |
| 84 | + |
| 85 | + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} |
| 86 | + # Skip if no package.json |
| 87 | + if: ${{ steps.versions.outputs.npmVersion }} |
| 88 | + run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}' |
| 89 | + |
| 90 | + - name: Get php version |
| 91 | + id: php-versions |
| 92 | + uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1 |
| 93 | + with: |
| 94 | + filename: ${{ env.APP_NAME }}/appinfo/info.xml |
| 95 | + |
| 96 | + - name: Set up php ${{ steps.php-versions.outputs.php-min }} |
| 97 | + uses: shivammathur/setup-php@ccf2c627fe61b1b4d924adfcbd19d661a18133a0 # v2.35.2 |
| 98 | + with: |
| 99 | + php-version: ${{ steps.php-versions.outputs.php-min }} |
| 100 | + coverage: none |
| 101 | + env: |
| 102 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 103 | + |
| 104 | + - name: Check composer.json |
| 105 | + id: check_composer |
| 106 | + uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0 |
| 107 | + with: |
| 108 | + files: "${{ env.APP_NAME }}/composer.json" |
| 109 | + |
| 110 | + - name: Install composer dependencies |
| 111 | + if: steps.check_composer.outputs.files_exists == 'true' |
| 112 | + run: | |
| 113 | + cd ${{ env.APP_NAME }} |
| 114 | + composer install --no-dev |
| 115 | +
|
| 116 | + - name: Build ${{ env.APP_NAME }} |
| 117 | + # Skip if no package.json |
| 118 | + if: ${{ steps.versions.outputs.nodeVersion }} |
| 119 | + env: |
| 120 | + CYPRESS_INSTALL_BINARY: 0 |
| 121 | + run: | |
| 122 | + cd ${{ env.APP_NAME }} |
| 123 | + npm ci |
| 124 | + npm run build --if-present |
| 125 | +
|
| 126 | + - name: Check Krankerl config |
| 127 | + id: krankerl |
| 128 | + uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0 |
| 129 | + with: |
| 130 | + files: ${{ env.APP_NAME }}/krankerl.toml |
| 131 | + |
| 132 | + - name: Install Krankerl |
| 133 | + if: steps.krankerl.outputs.files_exists == 'true' |
| 134 | + run: | |
| 135 | + wget https://github.com/ChristophWurst/krankerl/releases/download/v0.14.0/krankerl_0.14.0_amd64.deb |
| 136 | + sudo dpkg -i krankerl_0.14.0_amd64.deb |
| 137 | +
|
| 138 | + - name: Package ${{ env.APP_NAME }} ${{ env.APP_VERSION }} with krankerl |
| 139 | + if: steps.krankerl.outputs.files_exists == 'true' |
| 140 | + run: | |
| 141 | + cd ${{ env.APP_NAME }} |
| 142 | + krankerl package |
| 143 | +
|
| 144 | + - name: Package ${{ env.APP_NAME }} ${{ env.APP_VERSION }} with makefile |
| 145 | + if: steps.krankerl.outputs.files_exists != 'true' |
| 146 | + run: | |
| 147 | + cd ${{ env.APP_NAME }} |
| 148 | + make appstore |
| 149 | +
|
| 150 | + - name: Checkout server ${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }} |
| 151 | + continue-on-error: true |
| 152 | + id: server-checkout |
| 153 | + run: | |
| 154 | + NCVERSION='${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }}' |
| 155 | + wget --quiet https://download.nextcloud.com/server/releases/latest-$NCVERSION.zip |
| 156 | + unzip latest-$NCVERSION.zip |
| 157 | +
|
| 158 | + - name: Checkout server master fallback |
| 159 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 160 | + if: ${{ steps.server-checkout.outcome != 'success' }} |
| 161 | + with: |
| 162 | + persist-credentials: false |
| 163 | + submodules: true |
| 164 | + repository: nextcloud/server |
| 165 | + path: nextcloud |
| 166 | + |
| 167 | + - name: Sign app |
| 168 | + run: | |
| 169 | + # Extracting release |
| 170 | + cd ${{ env.APP_NAME }}/build/artifacts |
| 171 | + tar -xvf ${{ env.APP_NAME }}.tar.gz |
| 172 | + cd ../../../ |
| 173 | + # Setting up keys |
| 174 | + echo '${{ secrets.APP_PRIVATE_KEY }}' > ${{ env.APP_NAME }}.key |
| 175 | + wget --quiet "https://github.com/nextcloud/app-certificate-requests/raw/master/${{ env.APP_NAME }}/${{ env.APP_NAME }}.crt" |
| 176 | + # Signing |
| 177 | + php nextcloud/occ integrity:sign-app --privateKey=../${{ env.APP_NAME }}.key --certificate=../${{ env.APP_NAME }}.crt --path=../${{ env.APP_NAME }}/build/artifacts/${{ env.APP_NAME }} |
| 178 | + # Rebuilding archive |
| 179 | + cd ${{ env.APP_NAME }}/build/artifacts |
| 180 | + tar -zcvf ${{ env.APP_NAME }}.tar.gz ${{ env.APP_NAME }} |
| 181 | +
|
| 182 | + - name: Attach tarball to github release |
| 183 | + uses: svenstaro/upload-release-action@81c65b7cd4de9b2570615ce3aad67a41de5b1a13 # v2.11.2 |
| 184 | + id: attach_to_release |
| 185 | + with: |
| 186 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 187 | + file: ${{ env.APP_NAME }}/build/artifacts/${{ env.APP_NAME }}.tar.gz |
| 188 | + asset_name: ${{ env.APP_NAME }}-${{ env.APP_VERSION }}.tar.gz |
| 189 | + tag: ${{ github.ref }} |
| 190 | + overwrite: true |
| 191 | + |
| 192 | + - name: Upload app to Nextcloud appstore |
| 193 | + uses: nextcloud-releases/nextcloud-appstore-push-action@a011fe619bcf6e77ddebc96f9908e1af4071b9c1 # v1.0.3 |
| 194 | + with: |
| 195 | + app_name: ${{ env.APP_NAME }} |
| 196 | + appstore_token: ${{ secrets.APPSTORE_TOKEN }} |
| 197 | + download_url: ${{ steps.attach_to_release.outputs.browser_download_url }} |
| 198 | + app_private_key: ${{ secrets.APP_PRIVATE_KEY }} |
0 commit comments