|
| 1 | +name: Package Latest |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +env: |
| 13 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: package-latest |
| 17 | + cancel-in-progress: false |
| 18 | + |
| 19 | +jobs: |
| 20 | + package-latest: |
| 21 | + name: Build latest install package |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + |
| 30 | + - name: Setup Node.js |
| 31 | + uses: actions/setup-node@v4 |
| 32 | + with: |
| 33 | + node-version: "24" |
| 34 | + |
| 35 | + - name: Install tools |
| 36 | + run: | |
| 37 | + sudo apt-get update |
| 38 | + sudo apt-get install -y php-cli php-xml zip unzip libxml2-utils |
| 39 | + gh --version |
| 40 | +
|
| 41 | + - name: Install frontend dependencies |
| 42 | + run: | |
| 43 | + if [ -f package-lock.json ]; then |
| 44 | + npm ci --ignore-scripts --legacy-peer-deps |
| 45 | + else |
| 46 | + npm install --ignore-scripts --legacy-peer-deps |
| 47 | + fi |
| 48 | +
|
| 49 | + - name: Read extension version |
| 50 | + id: version |
| 51 | + run: | |
| 52 | + version="$(php -r '$xml = simplexml_load_file("meta.xml"); echo trim((string) $xml->version);')" |
| 53 | + if [ -z "$version" ]; then |
| 54 | + echo "Unable to read version from meta.xml" >&2 |
| 55 | + exit 1 |
| 56 | + fi |
| 57 | + echo "version=$version" >> "$GITHUB_OUTPUT" |
| 58 | +
|
| 59 | + - name: Validate package inputs |
| 60 | + run: | |
| 61 | + find plib htdocs \( -name '*.php' -o -name '*.phtml' \) -print0 \ |
| 62 | + | sort -z \ |
| 63 | + | xargs -0 -n1 php -l |
| 64 | + npm test |
| 65 | + xmllint --noout meta.xml |
| 66 | + node -e "JSON.parse(require('fs').readFileSync('packaging/manifest.json', 'utf8'))" |
| 67 | + sh -n packaging/build.sh |
| 68 | +
|
| 69 | + - name: Build latest ZIP |
| 70 | + run: | |
| 71 | + version="${{ steps.version.outputs.version }}" |
| 72 | + sh packaging/build.sh |
| 73 | + zip -T "cloudflare-pro-${version}.zip" |
| 74 | + cp "cloudflare-pro-${version}.zip" cloudflare-pro.zip |
| 75 | +
|
| 76 | + - name: Prepare latest release notes |
| 77 | + run: | |
| 78 | + cat > latest-release-notes.md <<EOF |
| 79 | + Rolling latest package for Cloudflare Pro. |
| 80 | +
|
| 81 | + Version: ${{ steps.version.outputs.version }} |
| 82 | + Commit: ${GITHUB_SHA} |
| 83 | +
|
| 84 | + Install with: |
| 85 | +
|
| 86 | + \`\`\`sh |
| 87 | + plesk bin extension --install-url https://github.com/${GITHUB_REPOSITORY}/releases/download/latest/cloudflare-pro.zip |
| 88 | + \`\`\` |
| 89 | + EOF |
| 90 | +
|
| 91 | + - name: Move latest tag |
| 92 | + run: | |
| 93 | + git config user.name "github-actions[bot]" |
| 94 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 95 | + git tag -f latest "$GITHUB_SHA" |
| 96 | + git push origin refs/tags/latest --force |
| 97 | +
|
| 98 | + - name: Publish latest package |
| 99 | + env: |
| 100 | + GH_TOKEN: ${{ github.token }} |
| 101 | + run: | |
| 102 | + version="${{ steps.version.outputs.version }}" |
| 103 | + title="Cloudflare Pro latest (v${version})" |
| 104 | + if gh release view latest >/dev/null 2>&1; then |
| 105 | + gh release upload latest cloudflare-pro.zip --clobber |
| 106 | + gh release edit latest --title "$title" --notes-file latest-release-notes.md --prerelease |
| 107 | + else |
| 108 | + gh release create latest cloudflare-pro.zip \ |
| 109 | + --title "$title" \ |
| 110 | + --notes-file latest-release-notes.md \ |
| 111 | + --prerelease |
| 112 | + fi |
0 commit comments