-
Notifications
You must be signed in to change notification settings - Fork 1
145 lines (129 loc) · 5.51 KB
/
package.yml
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
name: Publish
on:
push:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
lega-commander: ['cli/lega-commander/**']
e2eTests: ['e2eTests/**']
clearinghouse: ['lib/clearinghouse/**']
crypt4gh: ['lib/crypt4gh/**']
tsd-file-api-client: ['lib/tsd-file-api-client/**']
cega-mock: ['services/cega-mock/**']
localega-tsd-proxy: ['services/localega-tsd-proxy/**']
mq-interceptor: ['services/mq-interceptor/**']
tsd-api-mock: ['services/tsd-api-mock/**']
- id: set-matrix
run: |
MATRIX=$(echo '${{ toJson(steps.changes.outputs) }}' | jq -c '{include: [to_entries[] | select(.value == "true") | {component: .key}]}')
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
update-version-and-publish:
needs: detect-changes
if: ${{ needs.detect-changes.outputs.matrix != '{"include":[]}' }}
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJson(needs.detect-changes.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Java
if: ${{ matrix.component != 'lega-commander' }}
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Set up Go
if: ${{ matrix.component == 'lega-commander' }}
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Setup Gradle
if: ${{ matrix.component != 'lega-commander' }}
uses: gradle/actions/[email protected]
- name: Determine build.gradle.kts path
id: gradle_path
run: |
COMPONENT="${{ matrix.component }}"
if [[ $COMPONENT == lega-commander ]]; then
GRADLE_PATH="cli/lega-commander/build.gradle.kts"
elif [[ $COMPONENT == e2eTests ]]; then
GRADLE_PATH="e2eTests/build.gradle.kts"
elif [[ $COMPONENT == clearinghouse || $COMPONENT == crypt4gh || $COMPONENT == tsd-file-api-client ]]; then
GRADLE_PATH="lib/$COMPONENT/build.gradle.kts"
else
GRADLE_PATH="services/$COMPONENT/build.gradle.kts"
fi
echo "gradle_path=$GRADLE_PATH" >> $GITHUB_OUTPUT
- name: Get current version
id: get_version
run: |
GRADLE_PATH="${{ steps.gradle_path.outputs.gradle_path }}"
if [[ ! -f $GRADLE_PATH ]]; then
echo "Error: build.gradle.kts not found at $GRADLE_PATH"
exit 1
fi
CURRENT_VERSION=$(grep -oP 'version = "\K[0-9]+\.[0-9]+\.[0-9]+' $GRADLE_PATH)
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
- name: Bump version
id: bump_version
run: |
CURRENT_VERSION="${{ steps.get_version.outputs.current_version }}"
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
NEW_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$((VERSION_PARTS[2] + 1))"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Update version in file
run: |
GRADLE_PATH="${{ steps.gradle_path.outputs.gradle_path }}"
sed -i "s/version = \".*\"/version = \"${{ steps.bump_version.outputs.new_version }}\"/" $GRADLE_PATH
- name: Build and publish
if: ${{ matrix.component != 'lega-commander' && matrix.component != 'e2eTests' }}
run: |
COMPONENT="${{ matrix.component }}"
if [[ $COMPONENT == clearinghouse || $COMPONENT == crypt4gh || $COMPONENT == tsd-file-api-client ]]; then
./gradlew :lib:$COMPONENT:build
./gradlew :lib:$COMPONENT:publish
fi
- name: Build and push Docker image
if: ${{ matrix.component != 'lega-commander' && matrix.component != 'clearinghouse' && matrix.component != 'crypt4gh' && matrix.component != 'tsd-file-api-client' && matrix.component != 'e2eTests' }}
uses: docker/build-push-action@v6
with:
context: ./services/${{ matrix.component }}
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ matrix.component }}-${{ steps.bump_version.outputs.new_version }}
ghcr.io/${{ github.repository }}:${{ matrix.component }}-latest
- name: Create and push new tag
if: ${{ matrix.component == 'lega-commander' }}
run: |
git tag v${{ steps.bump_lega_commander_version.outputs.new_lega_commander_version }} ${{ github.sha }}
- name: Run GoReleaser
if: ${{ matrix.component == 'lega-commander' }}
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --clean
workdir: cli/lega-commander
- name: Commit and push changes
run: |
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "Bump ${{ matrix.component }} version to ${{ steps.bump_version.outputs.new_version }}"
git push
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: "${{ matrix.component }}-${{ steps.bump_version.outputs.new_version }}"
name: "${{ matrix.component }} ${{ steps.bump_version.outputs.new_version }}"
generate_release_notes: true