CI_MAVEN #138
This file contains 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
# This is a basic workflow to help you get started with Actions | |
name: CI_MAVEN | |
# Controls when the action will run. Triggers the workflow on push or pull request | |
# events but only for the master branch | |
on: | |
workflow_run: | |
workflows: ["CI_BUILD", "CI_WEEKLYBUILD"] | |
branches: [master] | |
types: | |
- completed | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
check: | |
name: Check changed files | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
outputs: | |
run_job: ${{ steps.check_files.outputs.run_job || steps.check_nightly_commit.outputs.run_job }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Dump GitHub context | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
run: echo "$GITHUB_CONTEXT" | |
- name: check files | |
if: ${{ github.event.workflow.name == 'CI_BUILD' }} | |
id: check_files | |
run: | | |
echo "=============== list changed files ===============" | |
git diff --name-only HEAD^ HEAD | |
echo "run_job=false" >> $GITHUB_OUTPUT | |
echo "========== check paths of changed files ==========" | |
git diff --name-only HEAD^ HEAD > files.txt | |
while IFS= read -r file | |
do | |
echo $file | |
if [[ $file == ".github/workflows/maven.yaml"* ]]; then | |
echo "Recreate Maven was requested" | |
echo "run_job=true" >> $GITHUB_OUTPUT | |
break | |
fi | |
if [[ $file == "netreflected/"* ]]; then | |
echo "This file is under the directory 'netreflected/'." | |
echo "run_job=true" >> $GITHUB_OUTPUT | |
break | |
fi | |
echo "This files are not in a source directory no action required" | |
done < files.txt | |
- name: check last nightly commit | |
if: ${{ github.event.workflow.name == 'CI_WEEKLYBUILD' }} | |
id: check_nightly_commit | |
run: | | |
echo "run_job=false" >> $GITHUB_OUTPUT | |
echo "========== check commits of changes ==========" | |
git log -1 --pretty=%B HEAD^ HEAD > commit_message.txt | |
while IFS= read -r comment | |
do | |
echo $comment | |
if [[ $file == "Update sources after nightly build check"* ]]; then | |
echo "Nighly builds generated siomething" | |
echo "run_job=true" >> $GITHUB_OUTPUT | |
break | |
fi | |
done < commit_message.txt | |
# This workflow contains a single job called "build" | |
build_maven: | |
needs: check | |
if: needs.check.outputs.run_job == 'true' | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: '1' | |
submodules: 'true' | |
- name: Cache local Maven repository | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
# Install .NET SDKs | |
- name: Setup .NET 6.0 | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 6.0.x | |
- name: Compile to get local resources | |
run: dotnet build --no-incremental --configuration Release /p:Platform="Any CPU" src/net/NuReflector.sln | |
- name: Install gpg secret key | |
run: | | |
cat <(echo -e "${{ secrets.MAVEN_GPG_PRIVATE_KEY }}") | gpg --batch --import | |
gpg --list-secret-keys --keyid-format LONG | |
- name: Set up Apache Maven Central | |
uses: actions/setup-java@v1 | |
with: # running setup-java again overwrites the settings.xml | |
distribution: temurin | |
java-version: 11 | |
cache: 'maven' | |
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml | |
server-username: MAVEN_USERNAME # env variable for username in deploy | |
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy | |
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase | |
- name: Install local file to be used within Javadoc plugin of generated POM | |
run: mvn install:install-file -Dfile=./bin/net6.0/JCOBridge.jar -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.4.14 -Dpackaging=jar -DgeneratePom=true | |
- name: Extract net6.0 list | |
run: echo "NET_6_0_FILE_LIST=$(cat ./netreflected/net6.0.list)" >> $GITHUB_ENV | |
- name: Publish net6.0 to Apache Maven Central | |
run: for f in $NET_6_0_FILE_LIST; do mvn --file ./netreflected/$f --no-transfer-progress --batch-mode -Dgpg.passphrase=${{ secrets.MAVEN_GPG_PASSPHRASE }} deploy; done | |
env: | |
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} | |
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | |
- name: Extract net462 list | |
run: echo "NET_461_FILE_LIST=$(cat ./netreflected/net462.list)" >> $GITHUB_ENV | |
- name: Publish net462 to Apache Maven Central | |
run: for f in $NET_461_FILE_LIST; do mvn --file ./netreflected/$f --no-transfer-progress --batch-mode -Dgpg.passphrase=${{ secrets.MAVEN_GPG_PASSPHRASE }} deploy; done | |
env: | |
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} | |
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} |