-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (123 loc) · 4.34 KB
/
release_workflow.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
146
147
148
149
150
151
152
name: Release workflow
on:
workflow_dispatch: # Allows manual triggering
env:
JAVA_VERSION: 21
REGISTRY_IMAGE: ${{ vars.DOCKERHUB_USERNAME }}/shikkanime-core
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'corretto'
- name: Build and test
run: ./gradlew clean test --info
upgrade-version:
runs-on: ubuntu-latest
outputs:
v-version: ${{ steps.version.outputs.v-version }}
steps:
- uses: actions/checkout@v4
- name: Get next version
uses: reecetech/[email protected]
id: version
with:
scheme: conventional_commits
docker:
runs-on: ubuntu-latest
needs: [test, upgrade-version]
strategy:
fail-fast: false
matrix:
build_version: [slim, full]
steps:
- uses: actions/checkout@v4
# Pull the latest commits
- name: Pull latest commits
run: git pull
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'corretto'
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=raw,value=${{ matrix.build_version }}
type=raw,value=${{ matrix.build_version }}-${{ needs.upgrade-version.outputs.v-version }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Update version in build.gradle.kts
run: |
#!/bin/bash
PROJECT_VERSION=$(cat 'build.gradle.kts' | grep -oP 'version = "\K[^\\"]*' | head -n 1)
# Update the file
sed -i "s|$PROJECT_VERSION|${{ needs.upgrade-version.outputs.v-version }}|g" build.gradle.kts
- name: Build
run: gradle clean installDist
- name: Build docker file
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
build-args: BUILD_VERSION=${{ matrix.build_version }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ matrix.build_version }}
cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ matrix.build_version }},mode=max
push: true
push-commit:
runs-on: ubuntu-latest
needs: [upgrade-version, docker]
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Update version in build.gradle.kts
run: |
#!/bin/bash
PROJECT_VERSION=$(cat 'build.gradle.kts' | grep -oP 'version = "\K[^\\"]*' | head -n 1)
# Update the file
sed -i "s|$PROJECT_VERSION|${{ needs.upgrade-version.outputs.v-version }}|g" build.gradle.kts
# Set up Git
git config user.name Ziedelth
git config user.email ${{ secrets.USER_EMAIL }}
# Commit the changes
git add build.gradle.kts
git commit -m "Update version to ${{ needs.upgrade-version.outputs.v-version }}"
- name: Push changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.USER_TOKEN }}
branch: ${{ github.ref }}
force: true
push-tag:
runs-on: ubuntu-latest
needs: [upgrade-version, push-commit]
steps:
- uses: actions/checkout@v4
# Pull the latest commits
- name: Pull latest commits
run: git pull
- name: Push Git Tag
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git tag ${{ needs.upgrade-version.outputs.v-version }}
git push origin ${{ needs.upgrade-version.outputs.v-version }}