diff --git a/.ci/files/regenerate_metadata.sh b/.ci/files/regenerate_metadata.sh new file mode 100755 index 00000000..30a6c20d --- /dev/null +++ b/.ci/files/regenerate_metadata.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +echo "Regenerating metadata for p2-site..." +local releases=($(find . -maxdepth 1 -type d -regex "\./[0-9]+\.[0-9]+\.[0-9]+\..*" -printf '%f\n'| tr '.' '\0' | sort -t '\0' -k1,1nr -k2,2nr -k3,3nr -k4dr |awk -F '\0' '{printf "%s.%s.%s.%s\n", $1, $2, $3, $4}')) +# remove old releases +for i in "${releases[@]:5}"; do + pmd_ci_log_info "Removing old release $i..." + rm -rf "$i" +done +releases=("${releases[@]:0:5}") + +# regenerate metadata +local now +now=$(date +%s000) +local children="" +local children_index="" +for i in "${releases[@]}"; do + children="${children} \n" + children_index="${children_index} * [$i]($i/)\n" + echo "This is a Eclipse Update Site for the [PMD Eclipse Plugin](https://github.com/pmd/pmd-eclipse-plugin/) ${i}. + +Use to install the plugin with the Eclipse Update Manager. + +
+
Feature ID
+
net.sourceforge.pmd.eclipse
+
Version
+
${i}
+
+ +" > "$i"/index.md + + git add "$i"/index.md +done + +local site_name="PMD for Eclipse - Update Site" +local artifactsTemplate=" + + + + + + + +${children} +" +echo -e "${artifactsTemplate}" > compositeArtifacts.xml + +local contentTemplate=" + + + + + + + +${children} +" +echo -e "${contentTemplate}" > compositeContent.xml + +# p2.index +local p2_index="version = 1 +metadata.repository.factory.order = compositeContent.xml,\! +artifact.repository.factory.order = compositeArtifacts.xml,\!" +echo -e "${p2_index}" > p2.index + +# regenerate index.md +echo -e "This is a composite Eclipse Update Site for the [PMD Eclipse Plugin](https://github.com/pmd/pmd-eclipse-plugin/). + +Use to install the plugin with the Eclipse Update Manager. + +---- + +Versions available at : + +${children_index} + +For older versions, see + +" > index.md + diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml deleted file mode 100644 index ca23f0ab..00000000 --- a/.github/actions/build/action.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: 'Build' -description: 'Runs the build script' -inputs: - targetPlatform: - description: 'The eclipse target platform to build the plugins against' - required: true - deploy: - description: 'Whether to build only or also deploy the update site' - required: true - pmdCiSecretPassphrase: - description: 'Secret needed for releases' - required: false - githubToken: - description: 'The GitHub Token used for releases' - required: false - pmdCiGpgPrivateKey: - description: 'The GPG Private Key used for signing the release' - required: false - pmdCiGpgPassphrase: - description: 'The passphrase for the GPG private key used for signing the release' - required: false - -runs: - using: 'composite' - steps: - - name: Build - run: .ci/build.sh - shell: bash - env: - TARGET_PLATFORM: ${{ inputs.targetPlatform }} - DEPLOY: ${{ inputs.deploy }} - PMD_CI_SECRET_PASSPHRASE: ${{ inputs.pmdCiSecretPassphrase }} - GITHUB_TOKEN: ${{ inputs.githubToken }} - PMD_CI_GPG_PRIVATE_KEY: ${{ inputs.pmdCiGpgPrivateKey }} - MAVEN_GPG_PASSPHRASE: ${{ inputs.pmdCiGpgPassphrase }} diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 75f7c0d5..e3793f5b 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -1,11 +1,10 @@ name: 'Setup' -description: 'Setup java and ruby, check environment' +description: 'Setup java and xvfb' runs: using: 'composite' steps: - name: Set up JDK 21 - id: java21 uses: actions/setup-java@v4 with: distribution: temurin @@ -20,21 +19,11 @@ runs: key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', '**/*.target') }} restore-keys: | ${{ runner.os }}-maven- - - name: Set up Ruby 3.3 - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.3 - - name: Setup Environment - shell: bash - run: | - echo "LANG=en_US.UTF-8" >> $GITHUB_ENV - echo "MAVEN_OPTS=-Dmaven.wagon.httpconnectionManager.ttlSeconds=180 -Dmaven.wagon.http.retryHandler.count=3" >> $GITHUB_ENV - echo "PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/30/scripts" >> $GITHUB_ENV - - name: Check Environment + - name: Setup xvfb + if: ${{ runner.os == 'Linux' }} shell: bash run: | - f=check-environment.sh; \ - mkdir -p .ci && \ - ( [ -e .ci/$f ] || curl -sSL "${PMD_CI_SCRIPTS_URL}/$f" > ".ci/$f" ) && \ - chmod 755 .ci/$f && \ - .ci/$f + #see https://github.com/GabrielBB/xvfb-action + sudo apt-get install --yes xvfb + sudo apt-get install --yes libgtk2.0-0 + echo 'xvfb_cmd=xvfb-run --auto-servernum' >> "$GITHUB_ENV" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aecf31f2..54581f15 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,53 +1,73 @@ -name: build +name: Build on: + pull_request: + merge_group: push: branches: - - main + - '**' + # don't run on dependabot branches. Dependabot will create pull requests, which will then be run instead + - '!dependabot/**' tags: - '**' - pull_request: + workflow_dispatch: schedule: # build it monthly: At 05:00 on day-of-month 1. - cron: '0 5 1 * *' - workflow_dispatch: + +# if another commit is added to the same branch or PR (same github.ref), +# then cancel already running jobs and start a new build. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read # to fetch code (actions/checkout) + +env: + LANG: 'en_US.UTF-8' jobs: # verify build on one node before multiple builds on different os are started fail-fast-build: name: verify (ubuntu-latest, 2025-03) - timeout-minutes: 60 + timeout-minutes: 30 + defaults: + run: + shell: bash runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - name: Setup Environment uses: ./.github/actions/setup - name: Build - uses: ./.github/actions/build - with: - targetPlatform: 2025-03 - deploy: true - pmdCiSecretPassphrase: ${{ secrets.PMD_CI_SECRET_PASSPHRASE }} - githubToken: ${{ secrets.GITHUB_TOKEN }} - pmdCiGpgPrivateKey: ${{ secrets.PMD_CI_GPG_PRIVATE_KEY }} - pmdCiGpgPassphrase: ${{ secrets.PMD_CI_GPG_PASSPHRASE }} + run: | + ${xvfb_cmd} ./mvnw --show-version --errors --batch-mode \ + verify - name: Upload screenshots of failed unit tests uses: actions/upload-artifact@v4 if: ${{ failure() }} with: - name: screenshots-ubuntu-latest-2025-03 + name: screenshots-ubuntu-latest path: net.sourceforge.pmd.eclipse.plugin.test/screenshots if-no-files-found: ignore + - name: Upload update-site + uses: actions/upload-artifact@v4 + with: + name: update-site + path: net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-*.zip build: needs: fail-fast-build name: verify (${{ matrix.os }}, ${{ matrix.targetPlatform }}) - timeout-minutes: 60 + timeout-minutes: 30 + defaults: + run: + shell: bash continue-on-error: false strategy: @@ -70,17 +90,18 @@ jobs: runs-on: ${{ matrix.os }} steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - name: Setup Environment uses: ./.github/actions/setup - name: Build - uses: ./.github/actions/build - with: - targetPlatform: ${{ matrix.targetPlatform }} - deploy: false + env: + TARGET_PLATFORM: ${{ matrix.targetPlatform }} + run: | + ${xvfb_cmd} ./mvnw --show-version --errors --batch-mode \ + verify \ + -Dtarget.platform="${TARGET_PLATFORM}" - name: Upload screenshots of failed unit tests uses: actions/upload-artifact@v4 diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 00000000..f10050c2 --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,306 @@ +name: Publish Release + +on: + workflow_run: + workflows: [Build] + types: + - completed + branches: + - '**' + - '!main' + - '!dependabot/**' + +permissions: + contents: read # to fetch code (actions/checkout) + +env: + LANG: 'en_US.UTF-8' + +jobs: + check-version: + # only run in the official pmd/pmd-eclipse-plugin repo, where we have access to the secrets and not on forks + # and only run for _successful_ push workflow runs on tags. + if: ${{ github.repository == 'pmd/pmd-eclipse-plugin' + && contains(fromJSON('["push", "workflow_dispatch"]'), github.event.workflow_run.event) + && github.event.workflow_run.head_branch != 'main' + && github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + timeout-minutes: 10 + defaults: + run: + shell: bash + outputs: + VERSION: ${{ steps.version.outputs.VERSION }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_branch }} + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + - name: Cache local Maven repository + uses: actions/cache@v4 + with: + path: | + ~/.m2/repository + net.sourceforge.pmd.eclipse.plugin/japicmp-data + # re-cache on changes in the pom and target files + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', '**/*.target') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Determine Version + id: version + env: + REF: ${{ github.event.workflow_run.head_branch }} + run: | + if ! git show-ref --exists "refs/tags/$REF"; then + echo "::error ::Tag $REF does not exist, aborting." + exit 1 + fi + + VERSION=$(./mvnw --batch-mode --no-transfer-progress help:evaluate -Dexpression=project.version -q -DforceStdout) + echo "Determined VERSION=$VERSION" + if [[ "$VERSION" = *-SNAPSHOT ]]; then + echo "::error ::VERSION=$VERSION is a snapshot version, aborting." + exit 1 + fi + echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" + - name: Add Job Summary + env: + WORKFLOW_RUN_DISPLAY_TITLE: ${{ github.event.workflow_run.display_title }} + WORKFLOW_RUN_NAME: ${{ github.event.workflow_run.name }} + WORKFLOW_RUN_NUMBER: ${{ github.event.workflow_run.run_number }} + WORKFLOW_RUN_HTML_URL: ${{ github.event.workflow_run.html_url }} + VERSION: ${{ steps.version.outputs.VERSION }} + TAG: ${{ github.event.workflow_run.head_branch }} + run: | + echo "### Run Info" >> "${GITHUB_STEP_SUMMARY}" + echo "Building Version: ${VERSION}" >> "${GITHUB_STEP_SUMMARY}" + echo "" >> "${GITHUB_STEP_SUMMARY}" + echo "Tag: ${TAG}" >> "${GITHUB_STEP_SUMMARY}" + echo "" >> "${GITHUB_STEP_SUMMARY}" + echo "Called by [${WORKFLOW_RUN_DISPLAY_TITLE} (${WORKFLOW_RUN_NAME} #${WORKFLOW_RUN_NUMBER})](${WORKFLOW_RUN_HTML_URL})" >> "${GITHUB_STEP_SUMMARY}" + echo "" >> "${GITHUB_STEP_SUMMARY}" + + create-signed-update-site: + needs: check-version + runs-on: ubuntu-latest + timeout-minutes: 30 + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_branch }} + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '21' + gpg-private-key: ${{ secrets.PMD_CI_GPG_PRIVATE_KEY }} + + - name: Cache local Maven repository + uses: actions/cache@v4 + with: + path: | + ~/.m2/repository + net.sourceforge.pmd.eclipse.plugin/japicmp-data + # re-cache on changes in the pom and target files + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', '**/*.target') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Build + env: + MAVEN_GPG_PASSPHRASE: ${{ secrets.PMD_CI_GPG_PASSPHRASE }} + run: | + ./mvnw --show-version --errors --batch-mode \ + verify \ + -Psign -DskipTests + + - name: Upload update-site + uses: actions/upload-artifact@v4 + with: + name: update-site + path: net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-*.zip + + create-release: + needs: [check-version, create-signed-update-site] + runs-on: ubuntu-latest + timeout-minutes: 10 + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_branch }} + - uses: actions/download-artifact@v4 + with: + name: update-site + - name: Prepare Release Notes + run: | + # extract the release notes + BEGIN_LINE=$(grep -n "^## " ReleaseNotes.md|head -1|cut -d ":" -f 1) + END_LINE=$(grep -n "^## " ReleaseNotes.md|head -2|tail -1|cut -d ":" -f 1) + END_LINE=$((END_LINE - 1)) + + RELEASE_BODY="A new PMD for Eclipse plugin version has been released. + It is available via the update site: https://pmd.github.io/pmd-eclipse-plugin-p2-site/ + + $(head -$END_LINE ReleaseNotes.md | tail -$((END_LINE - BEGIN_LINE))) + " + echo "${RELEASE_BODY}" > release_notes_prepared.md + - name: Create Release + env: + TAG_NAME: ${{ github.event.workflow_run.head_branch }} + VERSION: ${{ needs.check-version.outputs.VERSION }} + run: | + RELEASE_NAME="PMD For Eclipse ${VERSION}" + gh release create "$TAG_NAME" "net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-${VERSION}.zip" \ + --verify-tag \ + --notes-file release_notes_prepared.md \ + --title "$RELEASE_NAME" + + deploy-to-sourceforge-files: + needs: [check-version, create-signed-update-site] + # use environment sourceforge, where secrets/vars are configured for PMD_WEB_SOURCEFORGE_NET_DEPLOY_KEY + # and PMD_WEB_SOURCEFORGE_NET_KNOWN_HOSTS + environment: + name: sourceforge + url: https://sourceforge.net/projects/pmd/files/pmd-eclipse/zipped/ + runs-on: ubuntu-latest + timeout-minutes: 10 + defaults: + run: + shell: bash + steps: + - uses: actions/download-artifact@v4 + with: + name: update-site + - name: Setup ssh key for sourceforge + env: + WEB_SF_DEPLOY_KEY: ${{ secrets.PMD_WEB_SOURCEFORGE_NET_DEPLOY_KEY }} + WEB_SF_KNOWN_HOSTS: ${{ vars.PMD_WEB_SOURCEFORGE_NET_KNOWN_HOSTS }} + run: | + mkdir -p "${HOME}/.ssh" + chmod 700 "${HOME}/.ssh" + printenv WEB_SF_DEPLOY_KEY > "${HOME}/.ssh/web.sourceforge.net_deploy_key" + chmod 600 "${HOME}/.ssh/web.sourceforge.net_deploy_key" + echo " + Host web.sourceforge.net + IdentityFile=$HOME/.ssh/web.sourceforge.net_deploy_key + " > "$HOME/.ssh/config" + echo "${WEB_SF_KNOWN_HOSTS}" > "$HOME/.ssh/known_hosts" + - name: Upload to sourceforge + id: upload + env: + VERSION: ${{ needs.check-version.outputs.VERSION }} + PMD_SF_USER: adangel + run: | + uploadUrl="${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd-eclipse/zipped/" + rsync -avh \ + "net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-${VERSION}.zip" \ + "${uploadUrl}/net.sourceforge.pmd.eclipse.p2updatesite-SNAPSHOT.zip" + + - name: Cleanup ssh + if: ${{ always() }} + run: | + rm -rf "${HOME}/.ssh" + + deploy-to-pmd-eclipse-plugin-p2-site: + needs: [check-version, create-signed-update-site] + environment: + name: github-pages + url: https://pmd.github.io/pmd-eclipse-plugin-p2-site/ + runs-on: ubuntu-latest + timeout-minutes: 10 + defaults: + run: + shell: bash + steps: + - uses: actions/download-artifact@v4 + with: + name: update-site + - uses: actions/create-github-app-token@v2 + id: pmd-actions-helper-app-token + with: + app-id: ${{ secrets.PMD_ACTIONS_HELPER_ID }} + private-key: ${{ secrets.PMD_ACTIONS_HELPER_PRIVATE_KEY }} + owner: pmd + repositories: pmd-eclipse-plugin-p2-site + permission-actions: write + - name: Prepare Local P2 Repository + uses: actions/checkout@v4 + with: + repository: pmd/pmd-eclipse-plugin-p2-site + ref: gh-pages + path: current-p2-site + token: ${{ steps.pmd-actions-helper-app-token.outputs.token }} + - name: Update Local P2 Repository + env: + VERSION: ${{ needs.check-version.outputs.VERSION }} + run: | + cd current-p2-site + # https://api.github.com/users/pmd-actions-helper[bot] + git config user.name "pmd-actions-helper[bot]" + git config user.email "207160486+pmd-actions-helper[bot]@users.noreply.github.com" + + unzip -q -d "${VERSION}" "../net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-${VERSION}.zip" + git add "${VERSION}" + ../.ci/files/regenerate_metadata.sh + + # create a new single commit + git checkout --orphan=gh-pages-2 + git commit -a -m "Update pmd/pmd-eclipse-plugin-p2-site" + git push --force origin gh-pages-2:gh-pages + + create-sourceforge-blog-post: + needs: [check-version, create-signed-update-site] + # use environment sourceforge, where secrets/vars are configured for PMD_SF_BEARER_TOKEN + environment: + name: sourceforge + url: ${{ steps.upload.outputs.url_output }} + runs-on: ubuntu-latest + timeout-minutes: 10 + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_branch }} + - name: Prepare Release Notes + run: | + # extract the release notes + BEGIN_LINE=$(grep -n "^## " ReleaseNotes.md|head -1|cut -d ":" -f 1) + END_LINE=$(grep -n "^## " ReleaseNotes.md|head -2|tail -1|cut -d ":" -f 1) + END_LINE=$((END_LINE - 1)) + + RELEASE_BODY="A new PMD for Eclipse plugin version has been released. + It is available via the update site: https://pmd.github.io/pmd-eclipse-plugin-p2-site/ + + $(head -$END_LINE ReleaseNotes.md | tail -$((END_LINE - BEGIN_LINE))) + " + echo "${RELEASE_BODY}" > release_notes_prepared.md + - name: Create Blog Post + id: upload + env: + TAG_NAME: ${{ github.event.workflow_run.head_branch }} + VERSION: ${{ needs.check-version.outputs.VERSION }} + PMD_SF_BEARER_TOKEN: ${{ secrets.PMD_SF_BEARER_TOKEN }} + run: | + RELEASE_NAME="PMD For Eclipse ${VERSION}" + # See https://sourceforge.net/p/forge/documentation/Allura%20API/ + url_output=$(curl --silent --include --request POST \ + --header "Authorization: Bearer ${PMD_SF_BEARER_TOKEN}" \ + --form "labels=pmd-eclipse-plugin,release" \ + --form "state=published" \ + --form "text=> "$GITHUB_OUTPUT" diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml new file mode 100644 index 00000000..2e901c8f --- /dev/null +++ b/.github/workflows/publish-snapshot.yml @@ -0,0 +1,227 @@ +name: Publish Snapshot + +on: + workflow_run: + workflows: [Build] + types: + - completed + branches: + - main + +permissions: + contents: read # to fetch code (actions/checkout) + +env: + LANG: 'en_US.UTF-8' + +jobs: + check-version: + # only run in the official pmd/pmd-eclipse-plugin repo, where we have access to the secrets and not on forks + # and only run for _successful_ push workflow runs on branch "main". + if: ${{ github.repository == 'pmd/pmd-eclipse-plugin' + && contains(fromJSON('["push", "workflow_dispatch", "schedule"]'), github.event.workflow_run.event) + && github.event.workflow_run.head_branch == 'main' + && github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + timeout-minutes: 30 + defaults: + run: + shell: bash + outputs: + VERSION: ${{ steps.version.outputs.VERSION }} + steps: + - uses: actions/checkout@v4 + with: + ref: main + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '21' + - name: Cache local Maven repository + uses: actions/cache@v4 + with: + path: | + ~/.m2/repository + net.sourceforge.pmd.eclipse.plugin/japicmp-data + # re-cache on changes in the pom and target files + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', '**/*.target') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Determine Version + id: version + run: | + VERSION=$(./mvnw --batch-mode --no-transfer-progress help:evaluate -Dexpression=project.version -q -DforceStdout -Dtycho.mode=maven) + echo "Determined VERSION=$VERSION" + if [[ "$VERSION" != *-SNAPSHOT ]]; then + echo "::error ::VERSION=$VERSION is not a snapshot version, aborting." + exit 1 + fi + echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" + - name: Add Job Summary + env: + WORKFLOW_RUN_DISPLAY_TITLE: ${{ github.event.workflow_run.display_title }} + WORKFLOW_RUN_NAME: ${{ github.event.workflow_run.name }} + WORKFLOW_RUN_NUMBER: ${{ github.event.workflow_run.run_number }} + WORKFLOW_RUN_HTML_URL: ${{ github.event.workflow_run.html_url }} + VERSION: ${{ steps.version.outputs.VERSION }} + BRANCH: ${{ github.event.workflow_run.head_branch }} + run: | + echo "### Run Info" >> "${GITHUB_STEP_SUMMARY}" + echo "Building Version: ${VERSION}" >> "${GITHUB_STEP_SUMMARY}" + echo "" >> "${GITHUB_STEP_SUMMARY}" + echo "Branch: ${BRANCH}" >> "${GITHUB_STEP_SUMMARY}" + echo "" >> "${GITHUB_STEP_SUMMARY}" + echo "Called by [${WORKFLOW_RUN_DISPLAY_TITLE} (${WORKFLOW_RUN_NAME} #${WORKFLOW_RUN_NUMBER})](${WORKFLOW_RUN_HTML_URL})" >> "${GITHUB_STEP_SUMMARY}" + echo "" >> "${GITHUB_STEP_SUMMARY}" + + create-signed-update-site: + needs: check-version + runs-on: ubuntu-latest + timeout-minutes: 30 + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '21' + gpg-private-key: ${{ secrets.PMD_CI_GPG_PRIVATE_KEY }} + + - name: Cache local Maven repository + uses: actions/cache@v4 + with: + path: | + ~/.m2/repository + net.sourceforge.pmd.eclipse.plugin/japicmp-data + # re-cache on changes in the pom and target files + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', '**/*.target') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Build + env: + MAVEN_GPG_PASSPHRASE: ${{ secrets.PMD_CI_GPG_PASSPHRASE }} + run: | + ./mvnw --show-version --errors --batch-mode \ + verify \ + -Psign -DskipTests + + - name: Upload update-site + uses: actions/upload-artifact@v4 + with: + name: update-site + path: net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-*.zip + + deploy-to-sourceforge-files: + needs: [check-version, create-signed-update-site] + # use environment sourceforge, where secrets/vars are configured for PMD_WEB_SOURCEFORGE_NET_DEPLOY_KEY + # and PMD_WEB_SOURCEFORGE_NET_KNOWN_HOSTS + environment: + name: sourceforge + url: https://sourceforge.net/projects/pmd/files/pmd-eclipse/zipped/ + runs-on: ubuntu-latest + timeout-minutes: 10 + defaults: + run: + shell: bash + steps: + - uses: actions/download-artifact@v4 + with: + name: update-site + - name: Setup ssh key for sourceforge + env: + WEB_SF_DEPLOY_KEY: ${{ secrets.PMD_WEB_SOURCEFORGE_NET_DEPLOY_KEY }} + WEB_SF_KNOWN_HOSTS: ${{ vars.PMD_WEB_SOURCEFORGE_NET_KNOWN_HOSTS }} + run: | + mkdir -p "${HOME}/.ssh" + chmod 700 "${HOME}/.ssh" + printenv WEB_SF_DEPLOY_KEY > "${HOME}/.ssh/web.sourceforge.net_deploy_key" + chmod 600 "${HOME}/.ssh/web.sourceforge.net_deploy_key" + echo " + Host web.sourceforge.net + IdentityFile=$HOME/.ssh/web.sourceforge.net_deploy_key + " > "$HOME/.ssh/config" + echo "${WEB_SF_KNOWN_HOSTS}" > "$HOME/.ssh/known_hosts" + - name: Upload to sourceforge + id: upload + env: + VERSION: ${{ needs.check-version.outputs.VERSION }} + PMD_SF_USER: adangel + run: | + uploadUrl="${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd-eclipse/zipped/" + rsync -avh \ + "net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-*.zip" \ + "${uploadUrl}/net.sourceforge.pmd.eclipse.p2updatesite-SNAPSHOT.zip" + + - name: Cleanup ssh + if: ${{ always() }} + run: | + rm -rf "${HOME}/.ssh" + + deploy-to-pmd-eclipse-plugin-p2-site: + needs: [check-version, create-signed-update-site] + environment: + name: github-pages + url: https://pmd.github.io/pmd-eclipse-plugin-p2-site/ + runs-on: ubuntu-latest + timeout-minutes: 10 + defaults: + run: + shell: bash + steps: + - uses: actions/download-artifact@v4 + with: + name: update-site + - uses: actions/create-github-app-token@v2 + id: pmd-actions-helper-app-token + with: + app-id: ${{ secrets.PMD_ACTIONS_HELPER_ID }} + private-key: ${{ secrets.PMD_ACTIONS_HELPER_PRIVATE_KEY }} + owner: pmd + repositories: pmd-eclipse-plugin-p2-site + permission-actions: write + - name: Prepare Local P2 Repository + uses: actions/checkout@v4 + with: + repository: pmd/pmd-eclipse-plugin-p2-site + ref: gh-pages + path: current-p2-site + token: ${{ steps.pmd-actions-helper-app-token.outputs.token }} + - name: Update Local P2 Repository + env: + VERSION: ${{ needs.check-version.outputs.VERSION }} + run: | + cd current-p2-site + # https://api.github.com/users/pmd-actions-helper[bot] + git config user.name "pmd-actions-helper[bot]" + git config user.email "207160486+pmd-actions-helper[bot]@users.noreply.github.com" + + qualifiedVersion="$(basename ../net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-*.zip)" + qualifiedVersion="${qualifiedVersion%.zip}" + qualifiedVersion="${qualifiedVersion#net.sourceforge.pmd.eclipse.p2updatesite-}" + + rm -rf snapshot + unzip -q -d snapshot "../net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-*.zip" + echo "This is a Eclipse Update Site for the [PMD Eclipse Plugin](https://github.com/pmd/pmd-eclipse-plugin/) ${VERSION}. + + Use to install the plugin with the Eclipse Update Manager. + +
+
Feature ID
+
net.sourceforge.pmd.eclipse
+
Version
+
${qualifiedVersion}
+
+ + " > snapshot/index.md + git add snapshot + + # create a new single commit + git checkout --orphan=gh-pages-2 + git commit -a -m "Update pmd/pmd-eclipse-plugin-p2-site" + git push --force origin gh-pages-2:gh-pages