You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by pk...@apache.org on 2023/04/30 21:13:25 UTC
[logging-log4j-transform] 02/02: Add "deploy" configuration to CI
This is an automated email from the ASF dual-hosted git repository.
pkarwasz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/logging-log4j-transform.git
commit 3f575463952af535c369f8d297e0efc8188802b7
Author: Piotr P. Karwasz <pi...@karwasz.org>
AuthorDate: Sun Apr 30 23:12:58 2023 +0200
Add "deploy" configuration to CI
---
.github/workflows/build.yml | 93 +++++++++++++++++++++++++++++++++++++++++++++
pom.xml | 10 ++++-
2 files changed, 102 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 07ca01f..296a974 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -105,3 +105,96 @@ jobs:
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ deploy:
+
+ runs-on: ubuntu-latest
+ needs: merge
+ if: github.repository == 'apache/logging-log4j-transform' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/'))
+
+ steps:
+
+ - name: Checkout repository
+ uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # 3.5.2
+
+ - name: Set up Java & GPG
+ uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # 3.7.0
+ with:
+ distribution: temurin
+ java-version: 17
+ java-package: jdk
+ architecture: x64
+ cache: maven
+ server-id: ${{ github.ref == 'refs/heads/master' && 'apache.snapshots.https' || 'apache.releases.https' }}
+ server-username: NEXUS_USERNAME
+ server-password: NEXUS_PASSWORD
+ # We won't use `maven-gpg-plugin`, but this is convenient to import the GPG secret key
+ gpg-private-key: ${{ secrets.GPG_SECRET_KEY }}
+
+ - name: Export artifact version
+ run: |
+ export PROJECT_VERSION=$(./mvnw \
+ --quiet --batch-mode -DforceStdout=true \
+ -Dexpression=project.version \
+ help:evaluate \
+ | tail -n 1)
+ echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
+
+ - name: Check version (SNAPSHOT)
+ if: github.ref == 'refs/heads/master'
+ run: |
+ [[ "$PROJECT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT$ ]] || {
+ echo "was expecting a snapshot version, found: \"$PROJECT_VERSION\"" 1>&2
+ exit 1
+ }
+
+ - name: Check version (RELEASE)
+ if: startsWith(github.ref, 'refs/heads/release/')
+ run: |
+ [[ "${GITHUB_REF/refs\/heads\/release\//}" == "$PROJECT_VERSION" ]] || {
+ echo "git ref \"$GITHUB_REF\" mismatches with the version: \"$PROJECT_VERSION\"" 1>&2
+ exit 1
+ }
+ [[ "$PROJECT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || {
+ echo "was expecting a release version, found: \"$PROJECT_VERSION\"" 1>&2
+ exit 1
+ }
+ export CHANGELOG_VERSION=$(grep "^== " CHANGELOG.adoc | head -n 1 | sed -r 's/^== (.+) \(.+\)$/\1/')
+ [[ "$PROJECT_VERSION" == "$CHANGELOG_VERSION" ]] || {
+ echo "version \"$PROJECT_VERSION\" doesn't match the one in changelog: \"$CHANGELOG_VERSION\"" 1>&2
+ exit 1
+ }
+ export CURRENT_DATE=$(date +%Y-%m-%d)
+ export CHANGELOG_DATE=$(grep "^== " CHANGELOG.adoc | head -n 1 | sed -r 's/^== .+ \((.+)\)$/\1/')
+ [[ "$CURRENT_DATE" == "$CHANGELOG_DATE" ]] || {
+ echo "current date \"$CURRENT_DATE\" doesn't match the one in the changelog: \"$CHANGELOG_DATE\"" 1>&2
+ exit 1
+ }
+
+ - name: Deploy
+ run: |
+ gpg --list-secret-keys
+ ./mvnw \
+ --show-version --batch-mode --errors --no-transfer-progress \
+ -P release
+ env:
+ # `NEXUS_USERNAME` and `NEXUS_PASSWORD` are used in `~/.m2/settings.xml` created by `setup-java` action
+ NEXUS_USERNAME: ${{ github.ref == 'refs/heads/master' && secrets.NEXUS_USER || secrets.LOGGING_STAGE_DEPLOYER_USER }}
+ NEXUS_PASSWORD: ${{ github.ref == 'refs/heads/master' && secrets.NEXUS_PW || secrets.LOGGING_STAGE_DEPLOYER_PW }}
+ # `SIGN_KEY` is used by `sign-maven-plugin`
+ SIGN_KEY: ${{ secrets.GPG_SECRET_KEY }}
+
+ - name: Create artifacts (RELEASE)
+ if: startsWith(github.ref, 'refs/heads/release/')
+ run: |
+ export ZIP_FILEPATH="target/apache-log4j-transform-${PROJECT_VERSION}-src.zip"
+ git ls-files -z | xargs -0 zip -9 "$ZIP_FILEPATH" --
+ gpg --armor --detach-sign --yes --pinentry-mode error "$ZIP_FILEPATH"
+ sha512sum "$ZIP_FILEPATH" > "$ZIP_FILEPATH.sha512"
+
+ - name: Upload artifacts (RELEASE)
+ if: startsWith(github.ref, 'refs/heads/release/')
+ uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # 3.1.2
+ with:
+ name: Sources
+ path: target/apache-log4j-tools-*-src.zip*
diff --git a/pom.xml b/pom.xml
index 956070e..a787bcd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -180,8 +180,16 @@
<skipTests>true</skipTests>
</properties>
<build>
- <defaultGoal>deploy</defaultGoal>
<plugins>
+ <!-- We want to deploy the artifact to a staging location for perusal -->
+ <plugin>
+ <inherited>true</inherited>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <updateReleaseInfo>true</updateReleaseInfo>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>