Skip to content

Merge pull request #773 from xdev-software/develop #69

Merge pull request #773 from xdev-software/develop

Merge pull request #773 from xdev-software/develop #69

Workflow file for this run

name: Release
on:
push:
branches: [ master ]
# DO NOT RESTORE CACHE for critical release steps to prevent a (extremely unlikely) scenario
# where a supply chain attack could be achieved due to poisoned cache
jobs:
check-code:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v7
- parallel:
- name: Set up JDK
uses: actions/setup-java@v6
with:
java-version: '25'
distribution: 'temurin'
# Try to reuse existing cache from check-build
- name: Try restore Maven Cache
uses: actions/cache/restore@v6
with:
path: ~/.m2/repository
key: ${{ runner.os }}-mvn-build-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-mvn-build-
- name: Build with Maven
run: ../mvnw -B clean package -P ignore-service-loading -T2C
working-directory: src
- name: Check for uncommited changes
run: |
if [[ "$(git status --porcelain)" != "" ]]; then
echo ----------------------------------------
echo git status
echo ----------------------------------------
git status
echo ----------------------------------------
echo git diff
echo ----------------------------------------
git diff
echo ----------------------------------------
echo Troubleshooting
echo ----------------------------------------
echo "::error::Unstaged changes detected. Locally try running: git clean -ffdx && ./mvnw -B clean package"
exit 1
fi
prepare-release:
runs-on: ubuntu-latest
needs: [check-code]
timeout-minutes: 10
permissions:
contents: write
outputs:
upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- uses: actions/checkout@v7
- name: Configure Git
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
- name: Un-SNAP
run: ./mvnw -B versions:set -DremoveSnapshot -DprocessAllModules -DgenerateBackupPoms=false
- name: Get version
id: version
run: |
version=$(./mvnw -B help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "release=$version" >> $GITHUB_OUTPUT
echo "releasenumber=${version//[!0-9]/}" >> $GITHUB_OUTPUT
- name: Commit and Push
run: |
git add -A
git commit -m "Release ${{ steps.version.outputs.release }}"
git push origin
git tag v${{ steps.version.outputs.release }}
git push origin --tags
- name: Create Release
id: create-release
uses: shogo82148/actions-create-release@8674c0ecee617c8dfb006526bcc22a362c70b88a # v1
with:
tag_name: v${{ steps.version.outputs.release }}
release_name: v${{ steps.version.outputs.release }}
commitish: master
body: |
## [Changelog](https://github.com/${{ github.repository }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }})
See [Changelog#v${{ steps.version.outputs.release }}](https://github.com/${{ github.repository }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }}) for more information.
## Installation
Add the following lines to your pom:
```XML
<dependency>
<groupId>software.xdev.tci</groupId>
<artifactId>corresponding_module</artifactId>
<version>${{ steps.version.outputs.release }}</version>
</dependency>
```
You can also use the [BOM](https://github.com/${{ github.repository }}/tree/develop/bom) for easier dependency management.
publish-maven:
runs-on: ubuntu-latest
needs: [prepare-release]
timeout-minutes: 60
steps:
- uses: actions/checkout@v7
- name: Init Git and pull
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git pull
- name: Set up JDK
uses: actions/setup-java@v6
with: # running setup-java overwrites the settings.xml
distribution: 'temurin'
java-version: '25'
server-id: github-central
server-password-env-var: PACKAGES_CENTRAL_TOKEN
gpg-passphrase-env-var: MAVEN_GPG_PASSPHRASE
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Only import once
- name: Publish to GitHub Packages Central
run: ../mvnw -B deploy -P publish -DaltDeploymentRepository=github-central::https://maven.pkg.github.com/xdev-software/central
working-directory: src
env:
PACKAGES_CENTRAL_TOKEN: ${{ secrets.PACKAGES_CENTRAL_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Set up JDK
uses: actions/setup-java@v6
with: # running setup-java again overwrites the settings.xml
distribution: 'temurin'
java-version: '25'
server-id: sonatype-central-portal
server-username-env-var: MAVEN_CENTRAL_USERNAME
server-password-env-var: MAVEN_CENTRAL_TOKEN
gpg-passphrase-env-var: MAVEN_GPG_PASSPHRASE
- name: Publish to Central Portal
run: ../mvnw -B deploy -P publish,publish-sonatype-central-portal
working-directory: src
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.SONATYPE_MAVEN_CENTRAL_PORTAL_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_MAVEN_CENTRAL_PORTAL_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
build-pages:
runs-on: ubuntu-latest
needs: [prepare-release]
timeout-minutes: 15
steps:
- uses: actions/checkout@v7
- name: Init Git and pull
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git pull
- name: Setup - Java
uses: actions/setup-java@v6
with:
java-version: '25'
distribution: 'temurin'
# Try to reuse existing cache from check-build
- name: Try restore Maven Cache
uses: actions/cache/restore@v6
with:
path: ~/.m2/repository
key: ${{ runner.os }}-mvn-build-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-mvn-build-
- name: Remove not needed modules
run: |
sed -i '/<module>.*-demo<\/module>/d' pom.xml
- name: Build site
run: ../mvnw -B compile site -P site -T2C
working-directory: src
- name: Aggregate site
run: |
# Compile is required, otherwise dep resolution failure
echo "Looking up modules"
module_dirs=($(../mvnw -B -q --also-make compile exec:exec -Dexec.executable="pwd" -Dmaven.main.skip))
base_module_full="${module_dirs[0]}"
echo "Found modules - Src: $base_module_full"
base_cut_away_length=$((${#base_module_full}+1))
echo "BasePathLengthToCutAway: $base_cut_away_length"
is_first=true
for full_module_path in "${module_dirs[@]}"
do
if [ $is_first ]; then
echo "Skipping initial/base module"
is_first=false
continue
fi
m=${full_module_path:$base_cut_away_length}
echo "$m/target/site -> ./target/$m"
mkdir -p ./target/$m
cp -r $m/target/site ./target/$m
done
working-directory: src
- name: Upload pages artifact
uses: actions/upload-pages-artifact@v5
with:
path: src/target/site
deploy-pages:
runs-on: ubuntu-latest
needs: [build-pages]
timeout-minutes: 10
concurrency:
group: 'pages'
cancel-in-progress: false
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
after-release:
runs-on: ubuntu-latest
needs: [publish-maven]
timeout-minutes: 10
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v7
- name: Init Git and pull
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git pull
- name: Inc Version and SNAP
run: ./mvnw -B versions:set -DnextSnapshot -DprocessAllModules -DgenerateBackupPoms=false
- name: Git Commit and Push
run: |
git add -A
git commit -m "Preparing for next development iteration"
git push origin
- name: pull-request
env:
GH_TOKEN: ${{ github.token }}
run: |
gh_pr_up() {
gh pr create "$@" || gh pr edit "$@"
}
gh_pr_up -B "develop" \
--title "Sync back" \
--body "An automated PR to sync changes back"