Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export deployment data to calling workflow #270

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .github/workflows/deploy-release-reusable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ on:
description: Identifier used in the distribution artifact and Subversion repository folder filenames (e.g., `logging-parent`)
required: true
type: string
outputs:
project-version:
description: The version of the project
value: ${{ jobs.deploy.outputs.project-version }}
nexus-url:
description: The URL of the Nexus repository used
value: ${{ jobs.deploy.outputs.nexus-url }}
secrets:
GPG_SECRET_KEY:
description: GPG secret key for signing artifacts
Expand All @@ -48,6 +55,9 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
outputs:
project-version: ${{ steps.version.outputs.project-version }}
nexus-url: ${{ steps.nexus.outputs.nexus-url }}
steps:

- name: Checkout repository
Expand All @@ -72,6 +82,7 @@ jobs:
git config user.email private@logging.apache.org

- name: Export version
id: version
shell: bash
env:
GIT_BRANCH_NAME: ${{ github.ref_name }}
Expand All @@ -82,6 +93,8 @@ jobs:
}
export PROJECT_VERSION=$(echo "$GIT_BRANCH_NAME" | sed 's/^release\///')
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
# Export version to calling workflow
echo "project-version=$PROJECT_VERSION" >> $GITHUB_OUTPUT

- name: Set the Maven `revision` property
shell: bash
Expand Down Expand Up @@ -132,6 +145,7 @@ jobs:
fi

- name: Upload to Nexus
id: nexus
shell: bash
env:
# `NEXUS_USERNAME` and `NEXUS_PASSWORD` are used in `~/.m2/settings.xml` created by `setup-java` action
Expand All @@ -145,6 +159,8 @@ jobs:
-P deploy,release
export NEXUS_URL=$(awk '/^(stagingRepository.url)/ { gsub(/(^.+=|\\)/, ""); print $1 }' target/nexus-staging/staging/*.properties)
echo "NEXUS_URL=$NEXUS_URL" >> $GITHUB_ENV
# Export repository URL to calling workflow
echo "nexus-url=$NEXUS_URL" >> $GITHUB_OUTPUT

# Node.js cache is needed for Antora
- name: Set up Node.js cache
Expand All @@ -158,7 +174,7 @@ jobs:
# For that, we need to configure `dependabot` to update hundreds of dependencies listed in `package-lock.json`.
# That translates to a never ending rain of `dependabot` PRs.
# I doubt if the wasted CPU cycles worth the gain.
key: ${{ runner.os }}-nodejs-cache-${{ hashFiles('node', 'node_modules') }}
key: "${{ runner.os }}-nodejs-cache-${{ hashFiles('node', 'node_modules') }}"
# `actions/cache` doesn't recommend caching `node_modules`.
# Though none of its recipes fit our bill, since we install Node.js using `frontend-maven-plugin`.
# See https://github.com/actions/cache/blob/main/examples.md#node---npm
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/deploy-snapshot-reusable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ on:
description: The Java compiler version
default: 17
type: string
outputs:
project-version:
description: The version of the project
value: ${{ jobs.deploy.outputs.project-version }}
# Constant output for similarity with `deploy-release-reusable`
nexus-url:
description: The URL of the Nexus repository used
value: https://repository.apache.org/content/repositories/snapshots
secrets:
NEXUS_USERNAME:
description: Nexus snapshot repository username for deploying artifacts
Expand All @@ -35,6 +43,8 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
outputs:
project-version: ${{ steps.version.outputs.project-version }}
steps:

- name: Checkout repository
Expand All @@ -51,6 +61,7 @@ jobs:
server-password: NEXUS_PASSWORD

- name: Export version
id: version
shell: bash
run: |
export PROJECT_VERSION=$(./mvnw \
Expand All @@ -59,6 +70,8 @@ jobs:
help:evaluate \
| tail -n 1)
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
# Export version to calling workflow
echo "project-version=$PROJECT_VERSION" >> $GITHUB_OUTPUT

- name: Upload to Nexus
shell: bash
Expand All @@ -70,3 +83,4 @@ jobs:
./mvnw \
--show-version --batch-mode --errors --no-transfer-progress \
-P deploy
export NEXUS_URL=$(awk '/^(stagingRepository.url)/ { gsub(/(^.+=|\\)/, ""); print $1 }' target/nexus-staging/staging/*.properties)
10 changes: 10 additions & 0 deletions src/changelog/.11.x.x/export_deployment_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://logging.apache.org/xml/ns"
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
type="changed">
<issue id="246" link="https://github.com/apache/logging-parent/pull/246"/>
<description format="asciidoc">
The `deploy-*-reusable` workflows export the URL of the Nexus repository as `nexus-url` workflow output and the project version as `project-version`.
</description>
</entry>
Loading