Skip to content

Maven artifact publish #1

Maven artifact publish

Maven artifact publish #1

Workflow file for this run

name: Java CI
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout this repo
uses: actions/checkout@v4
- name: Set up JDK 1.8
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '8'
- name: Install xmlstarlet
run: sudo apt-get install -y xmlstarlet
- name: Build with Gradle
run: bash ./gradlew build
- name: Extract version from generated POM file
id: extract_version
run: |
VERSION=$(xmlstarlet sel -t -v "/project/version" build/publications/maven/pom-default.xml)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Checkout artifact repo
uses: actions/checkout@v4
with:
repository: 'RiV-chain/artifact'
token: ${{ secrets.github_token }}
- name: Create package directories
run: |
mkdir -p artifact/org/tdf/${{ github.event.repository.name }}/${{ env.VERSION }}
- name: Copy JAR, POM, SHA-1, and MD5 files
run: |
cp build/libs/org.tdf-${{ env.VERSION }}.jar artifact/org/tdf/${{ github.event.repository.name }}/${{ env.VERSION }}/
cp build/publications/maven/pom-default.xml artifact/org/tdf/${{ github.event.repository.name }}/${{ env.VERSION }}/org.tdf-${{ env.VERSION }}.pom
sha1sum artifact/org/tdf/${{ github.event.repository.name }}/${{ env.VERSION }}/org.tdf-${{ env.VERSION }}.jar > artifact/org/tdf/${{ github.event.repository.name }}/${{ env.VERSION }}/org.tdf-${{ env.VERSION }}.jar.sha1
md5sum artifact/org/tdf/${{ github.event.repository.name }}/${{ env.VERSION }}/org.tdf-${{ env.VERSION }}.jar > artifact/org/tdf/${{ github.event.repository.name }}/${{ env.VERSION }}/org.tdf-${{ env.VERSION }}.jar.md5
sha1sum artifact/org/tdf/${{ github.event.repository.name }}/${{ env.VERSION }}/org.tdf-${{ env.VERSION }}.pom > artifact/org/tdf/${{ github.event.repository.name }}/${{ env.VERSION }}/org.tdf-${{ env.VERSION }}.pom.sha1
md5sum artifact/org/tdf/${{ github.event.repository.name }}/${{ env.VERSION }}/org.tdf-${{ env.VERSION }}.pom > artifact/org/tdf/${{ github.event.repository.name }}/${{ env.VERSION }}/org.tdf-${{ env.VERSION }}.pom.md5
- name: Commit and push files
run: |
cd artifact
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Add build artifacts for version ${{ env.VERSION }}"
git push
env:
GITHUB_TOKEN: ${{ secrets.github_token }}