1+ name : Publish JAR to GitHub Pages
2+ on :
3+ push :
4+ branches :
5+ - main
6+ permissions :
7+ contents : write
8+ pages : write
9+ id-token : write
10+ jobs :
11+ publish-jar :
12+ runs-on : ubuntu-latest
13+ steps :
14+ - name : Checkout code
15+ uses : actions/checkout@v4
16+ with :
17+ token : ${{ secrets.GITHUB_TOKEN }}
18+ fetch-depth : 0
19+ - name : Set up JDK 17
20+ uses : actions/setup-java@v4
21+ with :
22+ java-version : ' 17'
23+ distribution : ' temurin'
24+ - name : Grant execute permission for gradlew
25+ run : chmod +x gradlew
26+ - name : Extract version from build.gradle
27+ id : extract_version
28+ run : |
29+ VERSION=$(./gradlew -q printVersion)
30+ echo "version=$VERSION" >> $GITHUB_OUTPUT
31+ echo "Extracted version: $VERSION"
32+ - name : Check if tag already exists
33+ id : check_tag
34+ run : |
35+ if git tag -l "${{ steps.extract_version.outputs.version }}" | grep -q "${{ steps.extract_version.outputs.version }}"; then
36+ echo "tag_exists=true" >> $GITHUB_OUTPUT
37+ echo "Tag ${{ steps.extract_version.outputs.version }} already exists and will be overwritten"
38+ else
39+ echo "tag_exists=false" >> $GITHUB_OUTPUT
40+ echo "Tag ${{ steps.extract_version.outputs.version }} does not exist"
41+ fi
42+ - name : Publish Maven artifacts to local repo
43+ run : ./gradlew publish
44+ env :
45+ GROUP_ID : io.nodelink.client
46+ ARTIFACT_ID : NodeLink-Client
47+ VERSION : ${{ steps.extract_version.outputs.version }}
48+ - name : Checkout target repository
49+ uses : actions/checkout@v4
50+ with :
51+ repository : nodelink-project/nodelink-project.github.io
52+ token : ${{ secrets.GH_TOKEN }}
53+ path : target-repo
54+ - name : Clean existing version folder
55+ run : |
56+ if [ -d "target-repo/NodeLink-Client/jar" ]; then
57+ echo "Cleaning existing NodeLink-Client/jar folder..."
58+ rm -rf target-repo/nodelink-client/jar
59+ fi
60+ mkdir -p target-repo/nodelink-client/jar
61+ - name : Copy new artifacts
62+ run : |
63+ cp -r build/repo/* target-repo/nodelink-client/jar/
64+ - name : Deploy to GitHub Pages
65+ run : |
66+ cd target-repo
67+ git config --local user.email "action@github.com"
68+ git config --local user.name "GitHub Action"
69+ git add .
70+ if git diff --staged --quiet; then
71+ echo "No changes to commit"
72+ else
73+ git commit -m "Update Orbit artifacts for version ${{ steps.extract_version.outputs.version }}"
74+ git push
75+ fi
76+ - name : Create and push Git tag (with override)
77+ run : |
78+ git config --local user.email "action@github.com"
79+ git config --local user.name "GitHub Action"
80+
81+ # S'assurer qu'on pousse vers le bon repository
82+ git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
83+
84+ # Supprimer le tag localement s'il existe
85+ git tag -d "${{ steps.extract_version.outputs.version }}" || true
86+
87+ # Supprimer le tag distant s'il existe
88+ git push origin --delete "${{ steps.extract_version.outputs.version }}" || true
89+
90+ # Créer et pousser le nouveau tag
91+ git tag -a "${{ steps.extract_version.outputs.version }}" -m "Release version ${{ steps.extract_version.outputs.version }}"
92+ git push origin "${{ steps.extract_version.outputs.version }}"
93+ env :
94+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments