|
| 1 | +name: Unstable Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - development |
| 7 | + |
| 8 | +jobs: |
| 9 | + release-management: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + |
| 13 | + - name: Checkout Code |
| 14 | + uses: actions/checkout@v3 |
| 15 | + with: |
| 16 | + fetch-depth: 0 |
| 17 | + ssh-key: ${{ secrets.DEPLOY_KEY }} |
| 18 | + |
| 19 | + - name: Set app env |
| 20 | + run: | |
| 21 | + echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV |
| 22 | +
|
| 23 | + - name: Get current version and append unstable suffix |
| 24 | + id: increment_version |
| 25 | + run: | |
| 26 | + git fetch origin main |
| 27 | + main_version=$(git show origin/main:appinfo/info.xml | grep -oP '(?<=<version>)[^<]+' || echo "") |
| 28 | + current_version=$(grep -oP '(?<=<version>)[^<]+' appinfo/info.xml || echo "") |
| 29 | +
|
| 30 | + IFS='.' read -ra main_version_parts <<< "$main_version" |
| 31 | + next_patch=$((main_version_parts[2] + 1)) |
| 32 | +
|
| 33 | + unstable_counter=1 |
| 34 | + if [[ $current_version =~ -unstable\.([0-9]+)$ ]]; then |
| 35 | + current_patch=$(echo $current_version | grep -oP '^[0-9]+\.[0-9]+\.(\d+)' | cut -d. -f3) |
| 36 | + if [ "$current_patch" -eq "$next_patch" ]; then |
| 37 | + unstable_counter=$((BASH_REMATCH[1] + 1)) |
| 38 | + fi |
| 39 | + fi |
| 40 | +
|
| 41 | + unstable_version="${main_version_parts[0]}.${main_version_parts[1]}.${next_patch}-unstable.${unstable_counter}" |
| 42 | +
|
| 43 | + echo "NEW_VERSION=$unstable_version" >> $GITHUB_ENV |
| 44 | + echo "new_version=$unstable_version" >> $GITHUB_OUTPUT |
| 45 | + echo "Main version: $main_version" |
| 46 | + echo "Current version: $current_version" |
| 47 | + echo "Using unstable version: $unstable_version" |
| 48 | +
|
| 49 | + - name: Update version in info.xml |
| 50 | + run: | |
| 51 | + sed -i "s|<version>.*</version>|<version>${{ env.NEW_VERSION }}</version>|" appinfo/info.xml |
| 52 | +
|
| 53 | + - name: Commit version update |
| 54 | + run: | |
| 55 | + git config --local user.email "action@github.com" |
| 56 | + git config --local user.name "GitHub Action" |
| 57 | +
|
| 58 | + if git diff --quiet && git diff --cached --quiet; then |
| 59 | + echo "No changes to commit" |
| 60 | + else |
| 61 | + git add appinfo/info.xml |
| 62 | + git commit -m "Bump unstable version to ${{ env.NEW_VERSION }} [skip ci]" |
| 63 | + git push |
| 64 | + fi |
| 65 | +
|
| 66 | + - name: Prepare Signing Certificate and Key |
| 67 | + run: | |
| 68 | + echo "${{ secrets.NEXTCLOUD_SIGNING_CERT }}" > signing-cert.crt |
| 69 | + echo "${{ secrets.NEXTCLOUD_SIGNING_KEY }}" > signing-key.key |
| 70 | +
|
| 71 | + - name: Install npm dependencies |
| 72 | + uses: actions/setup-node@v3 |
| 73 | + with: |
| 74 | + node-version: '18.x' |
| 75 | + |
| 76 | + - name: Set up PHP and install extensions |
| 77 | + uses: shivammathur/setup-php@v2 |
| 78 | + with: |
| 79 | + php-version: '8.2' |
| 80 | + extensions: zip, gd |
| 81 | + |
| 82 | + - run: npm ci |
| 83 | + - run: npm run build |
| 84 | + - run: composer install --no-dev --optimize-autoloader --classmap-authoritative |
| 85 | + |
| 86 | + - name: Copy the package files into the package |
| 87 | + run: | |
| 88 | + mkdir -p package/${{ github.event.repository.name }} |
| 89 | + rsync -av --progress \ |
| 90 | + --exclude='/package' \ |
| 91 | + --exclude='/.git' \ |
| 92 | + --exclude='/.github' \ |
| 93 | + --exclude='/.cursor' \ |
| 94 | + --exclude='/.vscode' \ |
| 95 | + --exclude='/node_modules' \ |
| 96 | + --exclude='/src' \ |
| 97 | + --exclude='/tests' \ |
| 98 | + --exclude='/package.json' \ |
| 99 | + --exclude='/package-lock.json' \ |
| 100 | + --exclude='/composer.json' \ |
| 101 | + --exclude='/composer.lock' \ |
| 102 | + --exclude='/phpcs.xml' \ |
| 103 | + --exclude='/phpmd.xml' \ |
| 104 | + --exclude='/psalm.xml' \ |
| 105 | + --exclude='/phpunit.xml' \ |
| 106 | + --exclude='/.phpunit.cache' \ |
| 107 | + --exclude='.phpunit.result.cache' \ |
| 108 | + --exclude='/jest.config.js' \ |
| 109 | + --exclude='/webpack.config.js' \ |
| 110 | + --exclude='/tsconfig.json' \ |
| 111 | + --exclude='/.babelrc' \ |
| 112 | + --exclude='/.eslintrc.js' \ |
| 113 | + --exclude='/.prettierrc' \ |
| 114 | + --exclude='/stylelint.config.js' \ |
| 115 | + --exclude='/.gitignore' \ |
| 116 | + --exclude='/.gitattributes' \ |
| 117 | + --exclude='/signing-key.key' \ |
| 118 | + --exclude='/signing-cert.crt' \ |
| 119 | + ./ package/${{ github.event.repository.name }}/ |
| 120 | +
|
| 121 | + - name: Create Tarball |
| 122 | + run: | |
| 123 | + cd package && tar -czf ../nextcloud-release.tar.gz ${{ github.event.repository.name }} |
| 124 | +
|
| 125 | + - name: Sign the TAR.GZ file with OpenSSL |
| 126 | + run: | |
| 127 | + openssl dgst -sha512 -sign signing-key.key nextcloud-release.tar.gz | openssl base64 -out nextcloud-release.signature |
| 128 | +
|
| 129 | + - name: Upload tarball as artifact |
| 130 | + uses: actions/upload-artifact@v4 |
| 131 | + with: |
| 132 | + name: nextcloud-release-${{ env.NEW_VERSION }} |
| 133 | + path: | |
| 134 | + nextcloud-release.tar.gz |
| 135 | + nextcloud-release.signature |
| 136 | + retention-days: 30 |
| 137 | + |
| 138 | + - name: Git Version |
| 139 | + id: version |
| 140 | + uses: codacy/git-version@2.7.1 |
| 141 | + with: |
| 142 | + release-branch: development |
| 143 | + |
| 144 | + - name: Upload Unstable Release |
| 145 | + uses: ncipollo/release-action@v1.12.0 |
| 146 | + with: |
| 147 | + tag: v${{ env.NEW_VERSION }} |
| 148 | + name: Unstable Release ${{ env.NEW_VERSION }} |
| 149 | + draft: false |
| 150 | + prerelease: true |
| 151 | + skipIfReleaseExists: true |
| 152 | + |
| 153 | + - name: Attach tarball to GitHub release |
| 154 | + uses: svenstaro/upload-release-action@v2 |
| 155 | + with: |
| 156 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 157 | + file: nextcloud-release.tar.gz |
| 158 | + asset_name: ${{ env.APP_NAME }}-${{ env.NEW_VERSION }}.tar.gz |
| 159 | + tag: v${{ env.NEW_VERSION }} |
| 160 | + overwrite: true |
| 161 | + |
| 162 | + - name: Upload app to Nextcloud appstore |
| 163 | + uses: nextcloud-releases/nextcloud-appstore-push-action@a011fe619bcf6e77ddebc96f9908e1af4071b9c1 |
| 164 | + with: |
| 165 | + app_name: ${{ env.APP_NAME }} |
| 166 | + appstore_token: ${{ secrets.NEXTCLOUD_APPSTORE_TOKEN }} |
| 167 | + download_url: https://github.com/${{ github.repository }}/releases/download/v${{ env.NEW_VERSION }}/${{ env.APP_NAME }}-${{ env.NEW_VERSION }}.tar.gz |
| 168 | + app_private_key: ${{ secrets.NEXTCLOUD_SIGNING_KEY }} |
| 169 | + nightly: true |
| 170 | + |
| 171 | + - name: Verify release |
| 172 | + run: | |
| 173 | + echo "App version: ${{ env.NEW_VERSION }}" |
| 174 | + echo "Tarball contents:" |
| 175 | + tar -tvf nextcloud-release.tar.gz | head -50 |
| 176 | + echo "info.xml contents:" |
| 177 | + tar -xOf nextcloud-release.tar.gz ${{ env.APP_NAME }}/appinfo/info.xml |
0 commit comments