Release version #45
Workflow file for this run
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
name: Build and publish release | |
on: | |
push: | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Maven Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: master | |
path: main | |
- name: Set up JDK for compilation | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: 'maven' | |
- name: Build weasis-dicom-tools | |
run: mvn -B clean install -f main | |
- name: Extract Maven project version | |
run: | | |
cd main | |
MVN_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) | |
echo "LIB_VERSION=${MVN_VERSION}" >> $GITHUB_ENV | |
id: project | |
- name: Checkout mvn-repo repository | |
uses: actions/checkout@v4 | |
with: | |
repository: nroduit/mvn-repo | |
path: mvn-repo | |
token: ${{ secrets.API_TOKEN_GITHUB }} | |
- name: Install xmlstarlet | |
run: sudo apt-get install xmlstarlet | |
- name: Commit the maven packages | |
run: | | |
cd mvn-repo | |
REPO=$(pwd) | |
PKGFOLDER="org/weasis/weasis-dicom-tools" | |
TAG_VERSION=${{ env.LIB_VERSION }} | |
F_META="maven-metadata.xml" | |
function update_metadata() { | |
cd ~/.m2/repository/${1} | |
find . -name "*.jar" -o -name "*.pom" | cpio -updm ${REPO}/${1} | |
cd ${REPO}/${1} | |
if [ ! -f ${F_META} ]; then | |
aritifactId=$(echo ${1} | awk -F'/' '{print $NF}') | |
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?> | |
<metadata> | |
<groupId>org.weasis</groupId> | |
<artifactId>${aritifactId}</artifactId> | |
<versioning> | |
<release></release> | |
<versions> | |
<version>${TAG_VERSION}</version> | |
</versions> | |
<lastUpdated></lastUpdated> | |
</versioning> | |
</metadata>" > ${F_META} | |
fi | |
xmlstarlet ed --inplace -u "//metadata/version" -v ${TAG_VERSION} -u "//metadata/versioning/release" -v ${TAG_VERSION} \ | |
-u "//metadata/versioning/lastUpdated" -v $(date "+%Y%m%d%H%M%S") ${F_META} | |
versions=$(xmlstarlet sel -t -m "//metadata/versioning/versions" -v version ${F_META}) | |
if ! printf '%s\n' "${versions[@]}" | grep -q -P "^${TAG_VERSION}$"; then | |
xmlstarlet ed --inplace -s "//metadata/versioning/versions" -t elem -n "version" -v ${TAG_VERSION} ${F_META} | |
fi | |
paths=($(find . -name "*.jar" -o -name "*.pom" -o -name "${F_META}")) | |
for file in ${paths[@]}; do | |
$(sha1sum "${file}" | awk '{printf $1}' > "${file}".sha1) | |
$(md5sum "${file}" | awk '{printf $1}' > "${file}".md5) | |
done | |
git add . | |
} | |
update_metadata ${PKGFOLDER} | |
update_metadata ${PKGFOLDER}-bom | |
git config user.name github-actions | |
git config user.email [email protected] | |
git commit -m "Add weasis-dicom-tools release" | |
git push |