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