Skip to content

Commit a0efde8

Browse files
committed
update github actions
1 parent 98e2821 commit a0efde8

2 files changed

Lines changed: 67 additions & 54 deletions

File tree

.github/workflows/build.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,24 @@ jobs:
3535
mkdir -p ~/.m2
3636
echo "<settings><pluginGroups><pluginGroup>org.sonarsource.scanner.maven</pluginGroup></pluginGroups></settings>" > ~/.m2/settings.xml
3737
38-
- name: Verify
39-
run: ./mvnw -e -B verify
40-
4138
- name: Cache SonarQube packages
4239
uses: actions/cache@v4
4340
with:
4441
path: ~/.sonar/cache
4542
key: ${{ runner.os }}-sonar
4643
restore-keys: ${{ runner.os }}-sonar
4744

45+
- name: Verify
46+
run: ./mvnw -e -B verify
47+
4848
- name: SonarQube Scan
49-
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && secrets.SONAR_TOKEN != ''
49+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
5050
env:
5151
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5252
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
53-
run: ./mvnw -e -B sonar:sonar -Dsonar.projectKey=green-code-initiative_creedengo-java -Dsonar.organization=green-code-initiative
53+
run: |
54+
if [ -z "$SONAR_TOKEN" ]; then
55+
echo "⚠️ SONAR_TOKEN is not set (Dependabot PR or external fork). Skipping SonarQube scan."
56+
else
57+
./mvnw -e -B sonar:sonar -Dsonar.projectKey=green-code-initiative_creedengo-java -Dsonar.organization=green-code-initiative
58+
fi

.github/workflows/tag_release.yml

Lines changed: 57 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
name: Tag Release
22

33
on:
4-
push:
5-
tags:
6-
- '[0-9]+.[0-9]+.[0-9]+'
4+
#push:
5+
# tags:
6+
# - '[0-9]+.[0-9]+.[0-9]+'
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: 'Release tag to deploy (e.g. 2.3.0). Leave empty to use the latest available tag.'
11+
required: false
12+
type: string
713

814
jobs:
915
checks:
@@ -15,66 +21,68 @@ jobs:
1521
- name: Check user permissions
1622
uses: 74th/workflow-permission-action@1.0.0
1723
with:
18-
users: dedece35,glalloue,jhertout,jules-delecour-dav,olegoaer,zippy1978,utarwyn
24+
users: dedece35,glalloue,jhertout,olegoaer,zippy1978,utarwyn
1925
build:
2026
name: Build And Release
2127
runs-on: ubuntu-latest
2228
needs: checks
23-
outputs:
24-
upload_url: ${{ steps.create_release.outputs.upload_url }}
2529
permissions:
2630
contents: write
2731
steps:
28-
- name: Checkout tag "${{ github.ref_name }}"
32+
- name: Checkout repository
2933
uses: actions/checkout@v3
3034
with:
31-
ref: ${{ github.ref_name }}
35+
fetch-depth: 0
36+
37+
- name: Resolve release tag
38+
id: resolve_tag
39+
run: |
40+
if [ -n "${{ inputs.tag }}" ]; then
41+
RELEASE_TAG="${{ inputs.tag }}"
42+
else
43+
RELEASE_TAG=$(git tag --sort=-version:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)
44+
fi
45+
if [ -z "$RELEASE_TAG" ]; then
46+
echo "No tag found. Please specify one as input."
47+
exit 1
48+
fi
49+
echo "Tag used: $RELEASE_TAG"
50+
echo "release_tag=$RELEASE_TAG" >> $GITHUB_ENV
51+
52+
- name: Checkout tag "${{ env.release_tag }}"
53+
uses: actions/checkout@v3
54+
with:
55+
ref: ${{ env.release_tag }}
56+
3257
- name: Extract release notes
3358
id: extract-release-notes
3459
uses: ffurrer2/extract-release-notes@v1
60+
3561
- name: Build project
36-
run: ./mvnw -e -B clean package -DskipTests
37-
- name: Create release
38-
id: create_release
39-
uses: actions/create-release@v1
4062
env:
41-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
# the plugin maven-release-plugin uses the environment variable VERSIONING_GIT_REF to determine the version to use when building the project.
64+
# By setting this variable to refs/tags/${{ env.release_tag }}, we are telling the plugin to use the specified tag as the project version.
65+
VERSIONING_GIT_REF: refs/tags/${{ env.release_tag }}
66+
run: mvn -e -B clean package -DskipTests -Drevision=${{ env.release_tag }}
67+
68+
- name: Resolve JAR filename
69+
id: resolve_jar
70+
run: |
71+
JAR_FILE=$(ls target/creedengo-java-plugin-*.jar | grep -v original | head -n 1)
72+
if [ -z "$JAR_FILE" ]; then
73+
echo "No JAR found in target/"
74+
exit 1
75+
fi
76+
echo "JAR found: $JAR_FILE"
77+
echo "jar_path=$JAR_FILE" >> $GITHUB_ENV
78+
79+
- name: Create release and upload asset
80+
uses: softprops/action-gh-release@v2
4281
with:
43-
tag_name: ${{ github.ref_name }}
44-
release_name: Release ${{ github.ref_name }}
82+
tag_name: ${{ env.release_tag }}
83+
name: Release ${{ env.release_tag }}
84+
body: ${{ steps.extract-release-notes.outputs.release_notes }}
85+
generate_release_notes: true
4586
draft: false
4687
prerelease: false
47-
body: ${{ steps.extract-release-notes.outputs.release_notes }}
48-
- name: Export plugin Jar files
49-
id: export_jar_files
50-
uses: actions/upload-artifact@v4
51-
with:
52-
name: creedengo-plugins
53-
path: target
54-
- name: Export UPLOAD_URL
55-
id: export_upload_url
56-
run: echo "upload_url=${{ steps.create_release.outputs.upload_url }}" >> $GITHUB_OUTPUT
57-
58-
upload:
59-
name: Upload Java Plugin
60-
runs-on: ubuntu-latest
61-
needs: build
62-
permissions:
63-
contents: write
64-
steps:
65-
- name: Import plugin JAR files
66-
id: import_jar_files
67-
uses: actions/download-artifact@v4
68-
with:
69-
name: creedengo-plugins
70-
path: target
71-
- name: Upload Release Asset - Java Plugin
72-
id: upload-release-asset
73-
uses: actions/upload-release-asset@v1
74-
env:
75-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76-
with:
77-
upload_url: ${{needs.build.outputs.upload_url}}
78-
asset_path: target/creedengo-java-plugin-${{ github.ref_name }}.jar
79-
asset_name: creedengo-java-plugin-${{ github.ref_name }}.jar
80-
asset_content_type: application/zip
88+
files: ${{ env.jar_path }}

0 commit comments

Comments
 (0)