Skip to content

Commit 85e0b8f

Browse files
authored
actualize commit info (#84)
1 parent 5619435 commit 85e0b8f

File tree

8 files changed

+62
-35
lines changed

8 files changed

+62
-35
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Retrieve commit info
2+
description: Retrieve commit info
3+
runs:
4+
using: "composite"
5+
steps:
6+
- shell: bash
7+
run: |
8+
if [[ "$GITHUB_REF_NAME" != "master" && "$GITHUB_REF_NAME" != "main" ]]; then
9+
SAFE_BRANCH_NAME=$(echo "$GITHUB_REF_NAME" | tr '/' '-')
10+
SAFE_BRANCH_NAME=$(echo "$SAFE_BRANCH_NAME" | sed 's/[^a-zA-Z0-9._-]//g')
11+
BRANCH_SUFFIX="-$SAFE_BRANCH_NAME"
12+
else
13+
BRANCH_SUFFIX=""
14+
fi
15+
echo "BRANCH_SUFFIX=$BRANCH_SUFFIX" >> $GITHUB_ENV
16+
17+
COMMIT_NUMBER=$(git rev-list HEAD --count)
18+
echo "COMMIT_NUMBER=$COMMIT_NUMBER" >> $GITHUB_ENV
19+
20+
SHA_7=${GITHUB_SHA::7}
21+
echo "SHA_7=$SHA_7" >> $GITHUB_ENV
22+
23+
REVISION="1.${COMMIT_NUMBER}-${SHA_7}${BRANCH_SUFFIX}"
24+
echo "REVISION=$REVISION" >> $GITHUB_ENV

.github/workflows/maven-library-build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,3 @@ jobs:
6767
6868
- name: Upload code coverage
6969
uses: codecov/codecov-action@v4
70-

.github/workflows/maven-service-build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,20 @@ jobs:
5656

5757
scan:
5858
name: Scan with Trivy
59-
needs: build
59+
needs: [build]
6060
runs-on: ubuntu-latest
6161
steps:
6262
- uses: actions/checkout@v4
63+
6364
- name: Install Trivy CLI
6465
run: |
6566
wget https://github.com/aquasecurity/trivy/releases/download/v0.39.1/trivy_0.39.1_Linux-64bit.deb
6667
sudo dpkg -i trivy_0.39.1_Linux-64bit.deb
68+
6769
- uses: actions/download-artifact@v4
6870
with:
6971
name: bom.json
72+
7073
- name: Run Trivy with SBOM
7174
run: trivy sbom --severity CRITICAL,HIGH --format sarif -o trivy-report.sarif ./bom.json
7275

.github/workflows/maven-service-deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ jobs:
6060
SLACK_COLOR: ${{ job.status }}
6161
SLACK_LINK_NAMES: true
6262
SLACK_FOOTER: ""
63+
6364
test-coverage:
6465
if: ${{ !inputs.ignore-coverage }}
6566
runs-on: ubuntu-22.04

.github/workflows/maven-swag-build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,3 @@ jobs:
5252

5353
- name: Build client jar
5454
run: mvn --batch-mode clean package -f pom.xml -P="client"
55-

.github/workflows/maven-swag-deploy.yml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ on:
1313
required: false
1414
default: "web_deploy"
1515
type: string
16+
java-version:
17+
description: 'Java version'
18+
required: false
19+
default: "15"
20+
type: string
21+
java-distribution:
22+
description: 'Java distribution'
23+
required: false
24+
default: "adopt"
25+
type: string
1626
secrets:
1727
server-username:
1828
required: true
@@ -75,23 +85,19 @@ jobs:
7585
path: ${{ inputs.dist-directory }}
7686

7787
- name: Retrieve commit info
78-
run: |
79-
echo "::set-output name=COMMIT_NUMBER::$(git rev-list HEAD --count)"
80-
echo "::set-output name=SHA_7::${GITHUB_SHA::7}"
8188
id: commit_info
89+
uses: ./.github/actions/commit-info
8290

83-
- name: Set artifact version
84-
run: |
85-
mvn versions:set versions:commit -DnewVersion="1.${{ steps.commit_info.outputs.COMMIT_NUMBER }}-${{ steps.commit_info.outputs.SHA_7 }}-server"
86-
87-
- name: Deploy server package
91+
- name: Deploy package
8892
uses: valitydev/[email protected]
8993
with:
94+
jdk-version: ${{ inputs.java-version }}
95+
jdk-distribution: ${{ inputs.java-distribution }}
9096
server-username: ${{ secrets.server-username }}
9197
server-password: ${{ secrets.server-password }}
9298
deploy-secret-key: ${{ secrets.deploy-secret-key }}
9399
deploy-secret-key-password: ${{ secrets.deploy-secret-key-password }}
94-
maven-args: '-Dcommit.number=${{ steps.commit_info.outputs.COMMIT_NUMBER }} -Drevision="1.${{ steps.commit_info.outputs.COMMIT_NUMBER }}-${{ steps.commit_info.outputs.SHA_7 }}-server" -P="server"'
100+
maven-args: '-Dcommit.number=${{ env.COMMIT_NUMBER }} -Drevision=${{ env.REVISION }}-server" -P="server"'
95101

96102
deploy-client:
97103
runs-on: ubuntu-22.04
@@ -109,23 +115,19 @@ jobs:
109115
path: ${{ inputs.dist-directory }}
110116

111117
- name: Retrieve commit info
112-
run: |
113-
echo "::set-output name=COMMIT_NUMBER::$(git rev-list HEAD --count)"
114-
echo "::set-output name=SHA_7::${GITHUB_SHA::7}"
115118
id: commit_info
119+
uses: ./.github/actions/commit-info
116120

117-
- name: Set artifact version
118-
run: |
119-
mvn --batch-mode versions:set versions:commit -DnewVersion="1.${{ steps.commit_info.outputs.COMMIT_NUMBER }}-${{ steps.commit_info.outputs.SHA_7 }}-client"
120-
121-
- name: Deploy client package
121+
- name: Deploy package
122122
uses: valitydev/[email protected]
123123
with:
124+
jdk-version: ${{ inputs.java-version }}
125+
jdk-distribution: ${{ inputs.java-distribution }}
124126
server-username: ${{ secrets.server-username }}
125127
server-password: ${{ secrets.server-password }}
126128
deploy-secret-key: ${{ secrets.deploy-secret-key }}
127129
deploy-secret-key-password: ${{ secrets.deploy-secret-key-password }}
128-
maven-args: '-Dcommit.number=${{ steps.commit_info.outputs.COMMIT_NUMBER }} -Drevision="1.${{ steps.commit_info.outputs.COMMIT_NUMBER }}-${{ steps.commit_info.outputs.SHA_7 }}-client" -P="client"'
130+
maven-args: '-Dcommit.number=${{ env.COMMIT_NUMBER }} -Drevision=${{ env.REVISION }}-client" -P="client"'
129131

130132
success-notify:
131133
runs-on: ubuntu-22.04

.github/workflows/maven-thrift-build.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,19 @@ jobs:
1919
runs-on: ubuntu-22.04
2020
steps:
2121
- name: Install thrift
22-
uses: valitydev/[email protected]
22+
uses: valitydev/[email protected]
23+
2324
- name: Checkout Repo
2425
uses: actions/checkout@v4
2526
with:
2627
fetch-depth: 0
28+
2729
- name: Set up Maven
2830
uses: actions/setup-java@v4
2931
with:
3032
java-version: ${{ inputs.java-version }}
3133
distribution: ${{ inputs.java-distribution }}
3234
cache: 'maven'
33-
- name: Retrieve commit info
34-
run: |
35-
echo "::set-output name=COMMIT_NUMBER::$(git rev-list HEAD --count)"
36-
echo "::set-output name=SHA_7::${GITHUB_SHA::7}"
37-
id: commit_info
38-
- name: Build package
39-
run: mvn --batch-mode -Dcommit.number=${{ steps.commit_info.outputs.COMMIT_NUMBER }} -Drevision="1.${{ steps.commit_info.outputs.COMMIT_NUMBER }}-${{ steps.commit_info.outputs.SHA_7 }}" clean compile -f pom.xml
4035

36+
- name: Build packages
37+
run: mvn -B clean verify

.github/workflows/maven-thrift-deploy.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,28 @@ jobs:
3030
runs-on: ubuntu-22.04
3131
steps:
3232
- name: Install thrift
33-
uses: valitydev/[email protected]
33+
uses: valitydev/[email protected]
34+
3435
- name: Checkout Repo
3536
uses: actions/checkout@v4
3637
with:
3738
fetch-depth: 0
39+
3840
- name: Retrieve commit info
39-
run: |
40-
echo "::set-output name=COMMIT_NUMBER::$(git rev-list HEAD --count)"
41-
echo "::set-output name=SHA_7::${GITHUB_SHA::7}"
4241
id: commit_info
42+
uses: ./.github/actions/commit-info
43+
4344
- name: Deploy package
4445
uses: valitydev/[email protected]
4546
with:
4647
jdk-version: ${{ inputs.java-version }}
47-
java-distribution: ${{ inputs.java-distribution }}
48+
jdk-distribution: ${{ inputs.java-distribution }}
4849
server-username: ${{ secrets.server-username }}
4950
server-password: ${{ secrets.server-password }}
5051
deploy-secret-key: ${{ secrets.deploy-secret-key }}
5152
deploy-secret-key-password: ${{ secrets.deploy-secret-key-password }}
52-
maven-args: '-Dcommit.number=${{ steps.commit_info.outputs.COMMIT_NUMBER }} -Drevision="1.${{ steps.commit_info.outputs.COMMIT_NUMBER }}-${{ steps.commit_info.outputs.SHA_7 }}"'
53+
maven-args: '-Dcommit.number=${{ env.COMMIT_NUMBER }} -Drevision=${{ env.REVISION }}'
54+
5355
notify:
5456
runs-on: ubuntu-22.04
5557
needs: [deploy]

0 commit comments

Comments
 (0)