|
| 1 | +name: Publish p2 Update Site |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - "v*" |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + pages: write |
| 14 | + id-token: write |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: "pages" |
| 18 | + cancel-in-progress: false |
| 19 | + |
| 20 | +jobs: |
| 21 | + build: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - name: Check out source |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Set up Java |
| 28 | + uses: actions/setup-java@v4 |
| 29 | + with: |
| 30 | + distribution: "temurin" |
| 31 | + java-version: "17" |
| 32 | + cache: "maven" |
| 33 | + |
| 34 | + - name: Build p2 repository with Tycho |
| 35 | + run: mvn -V -B -DskipTests=false clean verify |
| 36 | + |
| 37 | + - name: Configure GitHub Pages |
| 38 | + id: pages |
| 39 | + uses: actions/configure-pages@v5 |
| 40 | + |
| 41 | + - name: Prepare site content |
| 42 | + shell: bash |
| 43 | + run: | |
| 44 | + set -euo pipefail |
| 45 | +
|
| 46 | + repo_dir="repository/target/repository" |
| 47 | + if [ ! -d "${repo_dir}" ]; then |
| 48 | + echo "Expected p2 repository not found at ${repo_dir}." >&2 |
| 49 | + exit 1 |
| 50 | + fi |
| 51 | +
|
| 52 | + site_dir="site" |
| 53 | + rm -rf "${site_dir}" |
| 54 | + mkdir -p "${site_dir}" |
| 55 | +
|
| 56 | + # Publish the repository root at the Pages root. |
| 57 | + cp -a "${repo_dir}/." "${site_dir}/" |
| 58 | +
|
| 59 | + # If this is a tag build, also publish a versioned path and update /latest/. |
| 60 | + if [ "${GITHUB_REF_TYPE}" = "tag" ]; then |
| 61 | + mkdir -p "${site_dir}/releases/${GITHUB_REF_NAME}" "${site_dir}/latest" |
| 62 | + cp -a "${repo_dir}/." "${site_dir}/releases/${GITHUB_REF_NAME}/" |
| 63 | + cp -a "${repo_dir}/." "${site_dir}/latest/" |
| 64 | + fi |
| 65 | +
|
| 66 | + cat > "${site_dir}/index.html" <<EOF |
| 67 | + <!doctype html> |
| 68 | + <html lang="en"> |
| 69 | + <head> |
| 70 | + <meta charset="utf-8" /> |
| 71 | + <meta name="viewport" content="width=device-width, initial-scale=1" /> |
| 72 | + <title>Eclipse p2 Update Site</title> |
| 73 | + </head> |
| 74 | + <body> |
| 75 | + <h1>Eclipse p2 Update Site</h1> |
| 76 | + <p>Use this URL in Eclipse Install New Software:</p> |
| 77 | + <p><code>${{ steps.pages.outputs.base_url }}/</code></p> |
| 78 | + </body> |
| 79 | + </html> |
| 80 | + EOF |
| 81 | +
|
| 82 | + - name: Upload Pages artifact |
| 83 | + uses: actions/upload-pages-artifact@v3 |
| 84 | + with: |
| 85 | + path: site |
| 86 | + |
| 87 | + deploy: |
| 88 | + runs-on: ubuntu-latest |
| 89 | + needs: build |
| 90 | + environment: |
| 91 | + name: github-pages |
| 92 | + url: ${{ steps.deploy.outputs.page_url }} |
| 93 | + permissions: |
| 94 | + pages: write |
| 95 | + id-token: write |
| 96 | + steps: |
| 97 | + - name: Deploy to GitHub Pages |
| 98 | + id: deploy |
| 99 | + uses: actions/deploy-pages@v4 |
0 commit comments