-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (68 loc) · 2.62 KB
/
release.yml
File metadata and controls
81 lines (68 loc) · 2.62 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
name: Build library package on release
on:
release:
types:
- published
jobs:
build_library:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'temurin'
- name: Grant execute permission for Gradlew
run: chmod +x gradlew
- name: Extract release information
id: extract_info
run: |
RELEASE_NAME=${{ github.event.release.name }}
echo $RELEASE_NAME
if [[ "$RELEASE_NAME" == converter-* ]]; then
PROJECT="converter"
VERSION=${RELEASE_NAME#converter-}
else
PROJECT="library"
VERSION=$RELEASE_NAME
fi
PATTERN="^([0-9]+\.[0-9]+(\.[0-9]+)?)(-[A-Za-z0-9\.]+)*$"
if [[ ! "$VERSION" =~ $PATTERN ]]; then
echo "Invalid version number"
exit 1
fi
echo "::set-output name=project::$PROJECT"
echo "::set-output name=version::$VERSION"
- name: Validate X.Y or X.Y.Z version format for Maven publishing
id: validate_xyz
run: |
VERSION=${{ steps.extract_info.outputs.version }}
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]; then
echo "::set-output name=is_xyz_version::true"
echo "Version $VERSION matches X.Y or X.Y.Z format - Maven publishing will proceed"
else
echo "::set-output name=is_xyz_version::false"
echo "Version $VERSION does not match X.Y or X.Y.Z format - Maven publishing will be skipped"
fi
- name: Build, run tests and publish library
if: steps.extract_info.outputs.project == 'library' && steps.validate_xyz.outputs.is_xyz_version == 'true'
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew -Pversion=${{ steps.extract_info.outputs.version }} publish
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push converter service Docker image
if: steps.extract_info.outputs.project == 'converter'
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64
tags: ghcr.io/${{ github.repository_owner }}/hub-converter:${{ steps.extract_info.outputs.version }}
context: ./converter