|
| 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 | +name: Build and publish app release |
| 7 | + |
| 8 | +on: |
| 9 | + release: |
| 10 | + types: [published] |
| 11 | + |
| 12 | +env: |
| 13 | + PHP_VERSION: 8.1 |
| 14 | + |
| 15 | +jobs: |
| 16 | + build_and_publish: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + # Only allowed to be run on nextcloud-releases repositories |
| 20 | + if: ${{ github.repository_owner == 'cloud-py-api' }} # REPLACE THIS WITH YOUR ORGANIZATION NAME |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Check actor permission |
| 24 | + uses: skjnldsv/check-actor-permission@e591dbfe838300c007028e1219ca82cc26e8d7c5 # v2.1 |
| 25 | + with: |
| 26 | + require: write |
| 27 | + |
| 28 | + - name: Set app env |
| 29 | + run: | |
| 30 | + # Split and keep last |
| 31 | + echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV |
| 32 | + echo "APP_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV |
| 33 | +
|
| 34 | + - name: Checkout |
| 35 | + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 |
| 36 | + with: |
| 37 | + path: ${{ env.APP_NAME }} |
| 38 | + |
| 39 | + - name: Get appinfo data |
| 40 | + id: appinfo |
| 41 | + uses: skjnldsv/xpath-action@7e6a7c379d0e9abc8acaef43df403ab4fc4f770c # master |
| 42 | + with: |
| 43 | + filename: ${{ env.APP_NAME }}/appinfo/info.xml |
| 44 | + expression: "//info//dependencies//nextcloud/@min-version" |
| 45 | + |
| 46 | + - name: Read package.json node and npm engines version |
| 47 | + uses: skjnldsv/read-package-engines-version-actions@1bdcee71fa343c46b18dc6aceffb4cd1e35209c6 # v1.2 |
| 48 | + id: versions |
| 49 | + # Continue if no package.json |
| 50 | + continue-on-error: true |
| 51 | + with: |
| 52 | + path: ${{ env.APP_NAME }} |
| 53 | + fallbackNode: "^20" |
| 54 | + fallbackNpm: "^8" |
| 55 | + |
| 56 | + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} |
| 57 | + # Skip if no package.json |
| 58 | + if: ${{ steps.versions.outputs.nodeVersion }} |
| 59 | + uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3 |
| 60 | + with: |
| 61 | + node-version: ${{ steps.versions.outputs.nodeVersion }} |
| 62 | + |
| 63 | + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} |
| 64 | + # Skip if no package.json |
| 65 | + if: ${{ steps.versions.outputs.npmVersion }} |
| 66 | + run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" |
| 67 | + |
| 68 | + - name: Set up php ${{ env.PHP_VERSION }} |
| 69 | + uses: shivammathur/setup-php@1a18b2267f80291a81ca1d33e7c851fe09e7dfc4 # v2 |
| 70 | + with: |
| 71 | + php-version: ${{ env.PHP_VERSION }} |
| 72 | + coverage: none |
| 73 | + env: |
| 74 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + |
| 76 | + - name: Check composer.json |
| 77 | + id: check_composer |
| 78 | + uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 |
| 79 | + with: |
| 80 | + files: "${{ env.APP_NAME }}/composer.json" |
| 81 | + |
| 82 | + - name: Install composer dependencies |
| 83 | + if: steps.check_composer.outputs.files_exists == 'true' |
| 84 | + run: | |
| 85 | + cd ${{ env.APP_NAME }} |
| 86 | + composer install --no-dev |
| 87 | +
|
| 88 | + - name: Build ${{ env.APP_NAME }} |
| 89 | + # Skip if no package.json |
| 90 | + if: ${{ steps.versions.outputs.nodeVersion }} |
| 91 | + run: | |
| 92 | + cd ${{ env.APP_NAME }} |
| 93 | + npm ci |
| 94 | + npm run build |
| 95 | +
|
| 96 | + - name: Check Krankerl config |
| 97 | + id: krankerl |
| 98 | + uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 |
| 99 | + with: |
| 100 | + files: ${{ env.APP_NAME }}/krankerl.toml |
| 101 | + |
| 102 | + - name: Install Krankerl |
| 103 | + if: steps.krankerl.outputs.files_exists == 'true' |
| 104 | + run: | |
| 105 | + wget https://github.com/ChristophWurst/krankerl/releases/download/v0.14.0/krankerl_0.14.0_amd64.deb |
| 106 | + sudo dpkg -i krankerl_0.14.0_amd64.deb |
| 107 | +
|
| 108 | + - name: Package ${{ env.APP_NAME }} ${{ env.APP_VERSION }} with krankerl |
| 109 | + if: steps.krankerl.outputs.files_exists == 'true' |
| 110 | + run: | |
| 111 | + cd ${{ env.APP_NAME }} |
| 112 | + krankerl package |
| 113 | +
|
| 114 | + - name: Package ${{ env.APP_NAME }} ${{ env.APP_VERSION }} with makefile |
| 115 | + if: steps.krankerl.outputs.files_exists != 'true' |
| 116 | + run: | |
| 117 | + cd ${{ env.APP_NAME }} |
| 118 | + make appstore |
| 119 | +
|
| 120 | + - name: Checkout server ${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }} |
| 121 | + continue-on-error: true |
| 122 | + id: server-checkout |
| 123 | + run: | |
| 124 | + NCVERSION=${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }} |
| 125 | + wget --quiet https://download.nextcloud.com/server/releases/latest-$NCVERSION.zip |
| 126 | + unzip latest-$NCVERSION.zip |
| 127 | +
|
| 128 | + - name: Checkout server master fallback |
| 129 | + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 |
| 130 | + if: ${{ steps.server-checkout.outcome != 'success' }} |
| 131 | + with: |
| 132 | + submodules: true |
| 133 | + repository: nextcloud/server |
| 134 | + path: nextcloud |
| 135 | + |
| 136 | + - name: Sign app |
| 137 | + run: | |
| 138 | + # Extracting release |
| 139 | + cd ${{ env.APP_NAME }}/build/artifacts |
| 140 | + tar -xvf ${{ env.APP_NAME }}.tar.gz |
| 141 | + cd ../../../ |
| 142 | + # Setting up keys |
| 143 | + echo "${{ secrets.APP_PRIVATE_KEY }}" > ${{ env.APP_NAME }}.key |
| 144 | + wget --quiet "https://github.com/nextcloud/app-certificate-requests/raw/master/${{ env.APP_NAME }}/${{ env.APP_NAME }}.crt" |
| 145 | + # Signing |
| 146 | + 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 }} |
| 147 | + # Rebuilding archive |
| 148 | + cd ${{ env.APP_NAME }}/build/artifacts |
| 149 | + tar -zcvf ${{ env.APP_NAME }}.tar.gz ${{ env.APP_NAME }} |
| 150 | +
|
| 151 | + - name: Attach tarball to github release |
| 152 | + uses: svenstaro/upload-release-action@133984371c30d34e38222a64855679a414cb7575 # v2 |
| 153 | + id: attach_to_release |
| 154 | + with: |
| 155 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 156 | + file: ${{ env.APP_NAME }}/build/artifacts/${{ env.APP_NAME }}.tar.gz |
| 157 | + asset_name: ${{ env.APP_NAME }}-${{ env.APP_VERSION }}.tar.gz |
| 158 | + tag: ${{ github.ref }} |
| 159 | + overwrite: true |
| 160 | + |
| 161 | + - name: Upload app to Nextcloud appstore |
| 162 | + uses: nextcloud-releases/nextcloud-appstore-push-action@a011fe619bcf6e77ddebc96f9908e1af4071b9c1 # v1 |
| 163 | + with: |
| 164 | + app_name: ${{ env.APP_NAME }} |
| 165 | + appstore_token: ${{ secrets.APPSTORE_TOKEN }} |
| 166 | + download_url: ${{ steps.attach_to_release.outputs.browser_download_url }} |
| 167 | + app_private_key: ${{ secrets.APP_PRIVATE_KEY }} |
0 commit comments