|
| 1 | +# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors |
| 2 | +# SPDX-License-Identifier: AGPL-3.0-or-later |
| 3 | + |
| 4 | +name: Nightly Release |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + paths-ignore: |
| 11 | + - '**.md' |
| 12 | + - '.github/**' |
| 13 | + - '!.github/workflows/nightly-release.yml' |
| 14 | + |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: write |
| 19 | + actions: write |
| 20 | + |
| 21 | +jobs: |
| 22 | + nightly-release: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Check actor permission |
| 27 | + uses: skjnldsv/check-actor-permission@69e92a3c4711150929bca9fcf34448c5bf5526e7 # v3.0 |
| 28 | + with: |
| 29 | + require: write |
| 30 | + |
| 31 | + - name: Set app env |
| 32 | + run: | |
| 33 | + echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV |
| 34 | +
|
| 35 | + - name: Checkout |
| 36 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 37 | + with: |
| 38 | + persist-credentials: false |
| 39 | + submodules: true |
| 40 | + path: ${{ env.APP_NAME }} |
| 41 | + |
| 42 | + - name: Get app version number |
| 43 | + id: app-version |
| 44 | + uses: skjnldsv/xpath-action@f5b036e9d973f42c86324833fd00be90665fbf77 # v1.0.0 |
| 45 | + with: |
| 46 | + filename: ${{ env.APP_NAME }}/appinfo/info.xml |
| 47 | + expression: "//info//version/text()" |
| 48 | + |
| 49 | + - name: Set APP_VERSION env |
| 50 | + run: | |
| 51 | + echo "APP_VERSION=${{ fromJSON(steps.app-version.outputs.result).version }}" >> $GITHUB_ENV |
| 52 | +
|
| 53 | + - name: Get appinfo data |
| 54 | + id: appinfo |
| 55 | + uses: skjnldsv/xpath-action@f5b036e9d973f42c86324833fd00be90665fbf77 # v1.0.0 |
| 56 | + with: |
| 57 | + filename: ${{ env.APP_NAME }}/appinfo/info.xml |
| 58 | + expression: "//info//dependencies//nextcloud/@min-version" |
| 59 | + |
| 60 | + - name: Read package.json node and npm engines version |
| 61 | + uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3 |
| 62 | + id: versions |
| 63 | + # Continue if no package.json |
| 64 | + continue-on-error: true |
| 65 | + with: |
| 66 | + path: ${{ env.APP_NAME }} |
| 67 | + fallbackNode: '^20' |
| 68 | + fallbackNpm: '^10' |
| 69 | + |
| 70 | + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} |
| 71 | + # Skip if no package.json |
| 72 | + if: ${{ steps.versions.outputs.nodeVersion }} |
| 73 | + uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 |
| 74 | + with: |
| 75 | + node-version: ${{ steps.versions.outputs.nodeVersion }} |
| 76 | + |
| 77 | + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} |
| 78 | + # Skip if no package.json |
| 79 | + if: ${{ steps.versions.outputs.npmVersion }} |
| 80 | + run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}' |
| 81 | + |
| 82 | + - name: Get php version |
| 83 | + id: php-versions |
| 84 | + uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1 |
| 85 | + with: |
| 86 | + filename: ${{ env.APP_NAME }}/appinfo/info.xml |
| 87 | + |
| 88 | + - name: Set up php ${{ steps.php-versions.outputs.php-min }} |
| 89 | + uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0 |
| 90 | + with: |
| 91 | + php-version: ${{ steps.php-versions.outputs.php-min }} |
| 92 | + coverage: none |
| 93 | + env: |
| 94 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 95 | + |
| 96 | + - name: Check composer.json |
| 97 | + id: check_composer |
| 98 | + uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0 |
| 99 | + with: |
| 100 | + files: "${{ env.APP_NAME }}/composer.json" |
| 101 | + |
| 102 | + - name: Install composer dependencies |
| 103 | + if: steps.check_composer.outputs.files_exists == 'true' |
| 104 | + run: | |
| 105 | + cd ${{ env.APP_NAME }} |
| 106 | + composer install --no-dev |
| 107 | +
|
| 108 | + - name: Build ${{ env.APP_NAME }} |
| 109 | + # Skip if no package.json |
| 110 | + if: ${{ steps.versions.outputs.nodeVersion }} |
| 111 | + env: |
| 112 | + CYPRESS_INSTALL_BINARY: 0 |
| 113 | + run: | |
| 114 | + cd ${{ env.APP_NAME }} |
| 115 | + npm ci |
| 116 | + npm run build --if-present |
| 117 | +
|
| 118 | + - name: Check Krankerl config |
| 119 | + id: krankerl |
| 120 | + uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0 |
| 121 | + with: |
| 122 | + files: ${{ env.APP_NAME }}/krankerl.toml |
| 123 | + |
| 124 | + - name: Install Krankerl |
| 125 | + if: steps.krankerl.outputs.files_exists == 'true' |
| 126 | + run: | |
| 127 | + wget https://github.com/ChristophWurst/krankerl/releases/download/v0.14.0/krankerl_0.14.0_amd64.deb |
| 128 | + sudo dpkg -i krankerl_0.14.0_amd64.deb |
| 129 | +
|
| 130 | + - name: Package ${{ env.APP_NAME }} ${{ steps.version.outputs.version }} with krankerl |
| 131 | + if: steps.krankerl.outputs.files_exists == 'true' |
| 132 | + run: | |
| 133 | + cd ${{ env.APP_NAME }} |
| 134 | + krankerl package |
| 135 | +
|
| 136 | + - name: Checkout server ${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }} |
| 137 | + continue-on-error: true |
| 138 | + id: server-checkout |
| 139 | + run: | |
| 140 | + NCVERSION='${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }}' |
| 141 | + wget --quiet https://download.nextcloud.com/server/releases/latest-$NCVERSION.zip |
| 142 | + unzip latest-$NCVERSION.zip |
| 143 | +
|
| 144 | + - name: Checkout server master fallback |
| 145 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 146 | + if: ${{ steps.server-checkout.outcome != 'success' }} |
| 147 | + with: |
| 148 | + persist-credentials: false |
| 149 | + submodules: true |
| 150 | + repository: nextcloud/server |
| 151 | + path: nextcloud |
| 152 | + |
| 153 | + - name: Package ${{ env.APP_NAME }} ${{ steps.version.outputs.version }} with makefile |
| 154 | + if: steps.krankerl.outputs.files_exists != 'true' |
| 155 | + run: | |
| 156 | + cd ${{ env.APP_NAME }} |
| 157 | + # Setting up keys |
| 158 | + mkdir -p build/tools/certificates/ |
| 159 | + echo '${{ secrets.APP_PRIVATE_KEY }}' > build/tools/certificates/${{ env.APP_NAME }}.key |
| 160 | + make appstore |
| 161 | +
|
| 162 | + - name: Sign app |
| 163 | + run: | |
| 164 | + # Extracting release |
| 165 | + cd ${{ env.APP_NAME }}/build/artifacts |
| 166 | + tar -xvf ${{ env.APP_NAME }}.tar.gz |
| 167 | + cd ../../../ |
| 168 | + # Setting up keys |
| 169 | + echo '${{ secrets.APP_PRIVATE_KEY }}' > ${{ env.APP_NAME }}.key |
| 170 | + wget --quiet "https://github.com/nextcloud/app-certificate-requests/raw/master/${{ env.APP_NAME }}/${{ env.APP_NAME }}.crt" |
| 171 | + # Signing |
| 172 | + 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 }} |
| 173 | + # Rebuilding archive |
| 174 | + cd ${{ env.APP_NAME }}/build/artifacts |
| 175 | + tar -zcvf ${{ env.APP_NAME }}.tar.gz ${{ env.APP_NAME }} |
| 176 | +
|
| 177 | + - name: Extract version and create tag |
| 178 | + id: version |
| 179 | + run: | |
| 180 | + TIMESTAMP=$(date -u +"%Y%m%d-%H%M%S") |
| 181 | + TAG="nightly-${TIMESTAMP}" |
| 182 | +
|
| 183 | + echo "version=${{ env.APP_VERSION }}" >> $GITHUB_OUTPUT |
| 184 | + echo "tag=${TAG}" >> $GITHUB_OUTPUT |
| 185 | +
|
| 186 | + - name: Get recent commits for release notes |
| 187 | + id: release-notes |
| 188 | + run: | |
| 189 | + cd ${{ env.APP_NAME }} |
| 190 | + LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null | grep -v nightly || echo "") |
| 191 | +
|
| 192 | + if [ -z "$LAST_TAG" ]; then |
| 193 | + COMMITS=$(git log -10 --pretty=format:"- %s (%h)" --no-merges) |
| 194 | + else |
| 195 | + COMMITS=$(git log ${LAST_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges) |
| 196 | + fi |
| 197 | +
|
| 198 | + cat << EOF > release-notes.md |
| 199 | + ## 🌙 Nightly Build - ${{ steps.version.outputs.version }} |
| 200 | +
|
| 201 | + Automated nightly build from \`main\` branch. |
| 202 | +
|
| 203 | + ⚠️ **Development version** - may contain bugs or unstable features. |
| 204 | +
|
| 205 | + ### Recent Changes |
| 206 | +
|
| 207 | + $COMMITS |
| 208 | +
|
| 209 | + --- |
| 210 | + 🤖 Generated from commit [\`${GITHUB_SHA:0:7}\`](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) |
| 211 | + EOF |
| 212 | +
|
| 213 | + echo "notes<<EOF" >> $GITHUB_OUTPUT |
| 214 | + cat release-notes.md >> $GITHUB_OUTPUT |
| 215 | + echo "EOF" >> $GITHUB_OUTPUT |
| 216 | +
|
| 217 | + - name: Create GitHub release |
| 218 | + uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2.2.0 |
| 219 | + with: |
| 220 | + tag_name: ${{ steps.version.outputs.tag }} |
| 221 | + name: "Nightly ${{ steps.version.outputs.version }} (${{ steps.version.outputs.tag }})" |
| 222 | + body: ${{ steps.release-notes.outputs.notes }} |
| 223 | + prerelease: true |
| 224 | + draft: false |
| 225 | + |
| 226 | + - name: Attach tarball to github release |
| 227 | + uses: svenstaro/upload-release-action@6b7fa9f267e90b50a19fef07b3596790bb941741 # v2.11.3 |
| 228 | + id: attach_to_release |
| 229 | + with: |
| 230 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 231 | + file: ${{ env.APP_NAME }}/build/artifacts/${{ env.APP_NAME }}.tar.gz |
| 232 | + asset_name: ${{ env.APP_NAME }}-${{ steps.version.outputs.tag }}.tar.gz |
| 233 | + tag: ${{ steps.version.outputs.tag }} |
| 234 | + overwrite: true |
| 235 | + |
| 236 | + - name: Upload app to Nextcloud appstore (nightly) |
| 237 | + uses: nextcloud-releases/nextcloud-appstore-push-action@a011fe619bcf6e77ddebc96f9908e1af4071b9c1 # v1.0.3 |
| 238 | + with: |
| 239 | + app_name: ${{ env.APP_NAME }} |
| 240 | + appstore_token: ${{ secrets.APPSTORE_TOKEN }} |
| 241 | + download_url: ${{ steps.attach_to_release.outputs.browser_download_url }} |
| 242 | + app_private_key: ${{ secrets.APP_PRIVATE_KEY }} |
| 243 | + nightly: true |
0 commit comments