-
Notifications
You must be signed in to change notification settings - Fork 9
178 lines (149 loc) · 5.34 KB
/
build.yaml
File metadata and controls
178 lines (149 loc) · 5.34 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# This workflow will build and unit test the project.
# If the workflow is running on the "master" branch, then
# semantic-release is also run to create a new release (if
# warranted by the new commits being built).
name: Build & Release
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
# Default permissions: read-only
permissions:
contents: read
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
jobs:
detect-secrets:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
name: detect-secrets
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install detect-secrets
run: |
pip install --upgrade "git+https://github.com/ibm/detect-secrets.git@master#egg=detect-secrets"
- name: Run detect-secrets
run: |
detect-secrets scan --update .secrets.baseline
detect-secrets -v audit --report --fail-on-unaudited --fail-on-live --fail-on-audited-real .secrets.baseline
build:
name: build-test (java ${{matrix.java-version}})
needs: detect-secrets
runs-on: ubuntu-latest
strategy:
matrix:
java-version: ['11', '17']
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Java ${{matrix.java-version}}
uses: actions/setup-java@v4
with:
java-version: ${{matrix.java-version}}
distribution: 'temurin'
cache: 'maven'
- name: Build & Test
run: mvn -B clean verify -fae -DskipITs
results:
if: ${{ always() }}
runs-on: ubuntu-latest
name: Final Test Results
needs: [build]
steps:
- run: |
result="${{ needs.build.result }}"
if [[ $result == "success" || $result == "skipped" ]]; then
exit 0
else
exit 1
fi
create-release:
name: semantic-release
if: github.ref == 'refs/heads/master' && github.event_name == 'push' && !contains(github.event.head_commit.message, 'chore(release):')
needs: build
runs-on: ubuntu-latest
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Notify Slack - Release Started
run: |
curl -X POST "${{ secrets.SLACK_RELEASE_WEBHOOK_URL }}" \
-H 'Content-Type: application/json' \
-d '{
"sdk": "networking-java-sdk",
"language": "java",
"status": "started",
"actor": "${{ github.actor }}"
}'
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
cache: 'maven'
- name: Install Publishing Tools
run: |
pip install bump2version
npm ci
- name: Verify version consistency
run: |
# Extract versions from all files
BUMPVERSION_VERSION=$(grep "^current_version = " .bumpversion.cfg | cut -d'=' -f2 | tr -d ' ')
README_VERSION=$(grep "# IBM Cloud Networking Services Java SDK Version" README.md | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' || echo "not-found")
POM_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "Version in .bumpversion.cfg: $BUMPVERSION_VERSION"
echo "Version in README.md: $README_VERSION"
echo "Version in pom.xml: $POM_VERSION (should be 99-SNAPSHOT)"
# Verify pom.xml uses 99-SNAPSHOT (standard approach)
if [ "$POM_VERSION" != "99-SNAPSHOT" ]; then
echo "❌ ERROR: pom.xml version must be 99-SNAPSHOT (found: $POM_VERSION)"
echo "The version is set dynamically during publish, not in pom.xml"
exit 1
fi
# Verify .bumpversion.cfg and README.md match
if [ "$README_VERSION" != "not-found" ] && [ "$BUMPVERSION_VERSION" != "$README_VERSION" ]; then
echo "❌ ERROR: Version mismatch detected!"
echo ".bumpversion.cfg version ($BUMPVERSION_VERSION) must match README.md version ($README_VERSION)"
exit 1
fi
echo "✅ Version consistency check passed"
echo " - pom.xml: $POM_VERSION (correct)"
echo " - .bumpversion.cfg: $BUMPVERSION_VERSION"
echo " - README.md: $README_VERSION"
- name: Run semantic-release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: npx semantic-release
- name: Notify Slack - Release Failed
if: failure()
run: |
curl -X POST "${{ secrets.SLACK_RELEASE_WEBHOOK_URL }}" \
-H 'Content-Type: application/json' \
-d '{
"sdk": "networking-java-sdk",
"language": "java",
"status": "failed",
"actor": "${{ github.actor }}"
}'