-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (126 loc) · 4.21 KB
/
build.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: Build
on: [push, pull_request]
permissions:
contents: write
packages: write
jobs:
backend:
name: Backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build
run: ./gradlew build
- name: Artifact
uses: actions/upload-artifact@v3
with:
name: rm-monitor
path: ./build/libs
release:
name: Release
runs-on: ubuntu-latest
if: github.event_name == 'push'
needs: [ backend ]
outputs:
new_version: ${{ steps.should_push.outputs.new_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Fetch Previous version
id: get-previous-tag
uses: actions-ecosystem/[email protected]
- name: mkdir
run: |
mkdir dist
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: rm-monitor
path: ./dist
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: yarn global add semantic-release @semantic-release/changelog && semantic-release
- name: Fetch Current version
id: get-current-tag
uses: actions-ecosystem/[email protected]
- name: Output New Version
id: should_push
run: |
old_version=${{steps.get-previous-tag.outputs.tag}}
new_version=${{steps.get-current-tag.outputs.tag }}
if [ "$old_version" != "$new_version" ]; then
echo "new_version=$new_version" >> $GITHUB_OUTPUT
else
echo "new_version=" >> $GITHUB_OUTPUT
fi
docker:
runs-on: ubuntu-latest
needs: [ release ]
if: github.event_name == 'push' && needs.release.outputs.new_version != ''
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Buildx Cache
id: buildx-cache
uses: docker/setup-buildx-action@v3
with:
driver-opts: name=gha
- name: Buildx Cache Load
id: buildx-cache-load
uses: docker/setup-buildx-action@v3
with:
driver-opts: name=gha
action: load
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker Push
uses: docker/build-push-action@v5
if: github.event_name == 'push'
with:
context: .
push: true
platforms: linux/amd64
tags: |
scutrobot/rm-monitor:latest
scutrobot/rm-monitor:${{ needs.release.outputs.new_version }}
ghcr.io/scutrobot/rm-monitor:latest
ghcr.io/scutrobot/rm-monitor:${{ needs.release.outputs.new_version }}
build-args: |
VERSION=${{ needs.release.outputs.new_version }}
labels: |
org.opencontainers.image.source=https://github.com/scutrobot/rm-monitor
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.created=${{ github.event.head_commit.timestamp }}
org.opencontainers.image.version=${{ needs.release.outputs.new_version }}
org.opencontainers.image.title=rm-monitor ${{ needs.release.outputs.new_version }}
org.opencontainers.image.description="robomaster monitor"
org.opencontainers.image.licenses=AGPL-3.0
cache-from: type=gha
cache-to: type=gha,mode=max