Update build.gradle #33
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on: | |
| push: | |
| tags: | |
| - '*.*.*' | |
| name: Publish Release | |
| jobs: | |
| build: | |
| name: Publish Release | |
| runs-on: ubuntu-latest | |
| env: | |
| PKGCLD_REPO_URL: ${{ vars.PKGCLD_REPO_URL }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: '17' | |
| distribution: 'zulu' | |
| - name: Build with Gradle | |
| run: ./gradlew build | |
| - name: Get Release Version | |
| id: get_version | |
| run: VERSION=$(./gradlew currentVersion -q -Prelease.quiet) && echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Create Release | |
| run: | | |
| gh release create \ | |
| --generate-notes \ | |
| --title 'Release ${{ steps.get_version.outputs.VERSION }}' \ | |
| ${{ github.ref_name }} \ | |
| build/libs/http-step-${{ steps.get_version.outputs.VERSION }}.jar | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish to PackageCloud | |
| run: | | |
| if [ -z "$PKGCLD_WRITE_TOKEN" ]; then | |
| echo "::error::PKGCLD_WRITE_TOKEN must be set to publish to PackageCloud" | |
| exit 1 | |
| fi | |
| ./gradlew publishAllPublicationsToPackageCloudRepository | |
| env: | |
| PKGCLD_WRITE_TOKEN: ${{ secrets.PKGCLD_WRITE_TOKEN }} | |
| - name: Sign and upload GPG signatures to PackageCloud | |
| run: | | |
| set -e | |
| VERSION="${{ steps.get_version.outputs.VERSION }}" | |
| BASE_URL="${PKGCLD_REPO_URL:-https://packagecloud.io/pagerduty/rundeck-plugins/maven2}/org/rundeck/plugins/http-step/${VERSION}" | |
| echo "$SIGNING_KEY_B64" | base64 -d | gpg --batch --yes --import | |
| KEY_ID=$(gpg --list-secret-keys --with-colons | awk -F: '/^sec/ {print $5; exit}') | |
| sign_and_upload() { | |
| local FILE="$1" | |
| local REMOTE_NAME="$2" | |
| gpg --batch --yes --pinentry-mode loopback --passphrase "$SIGNING_PASSWORD" --default-key "$KEY_ID" --detach-sign --armor "$FILE" | |
| curl -sf -H "Authorization: Bearer ${PKGCLD_WRITE_TOKEN}" \ | |
| -X PUT --data-binary "@${FILE}.asc" \ | |
| "${BASE_URL}/${REMOTE_NAME}.asc" | |
| } | |
| sign_and_upload "build/libs/http-step-${VERSION}.jar" "http-step-${VERSION}.jar" | |
| sign_and_upload "build/libs/http-step-${VERSION}-sources.jar" "http-step-${VERSION}-sources.jar" | |
| sign_and_upload "build/libs/http-step-${VERSION}-javadoc.jar" "http-step-${VERSION}-javadoc.jar" | |
| sign_and_upload "build/publications/http-step/pom-default.xml" "http-step-${VERSION}.pom" | |
| env: | |
| SIGNING_KEY_B64: ${{ secrets.SIGNING_KEY_B64 }} | |
| SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} | |
| PKGCLD_WRITE_TOKEN: ${{ secrets.PKGCLD_WRITE_TOKEN }} |