139 lines (131 loc) · 4.03 KB
/
Release.yaml
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
name: Release
on:
push:
tags:
- '*'
env:
REPO_NAME: ${{ github.event.repository.name }}
LOWCASE_REPO_NAME: ${{ github.repository_owner}}/heartbeat
jobs:
build_backend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ vars.JAVA_VERSION || 19 }}
distribution: "adopt"
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: Set up Gradle
uses: gradle/gradle-build-action@v3.2.1
- name: Build
run: ./gradlew clean build
- uses: actions/upload-artifact@v4
with:
name: backend-app
path: backend/build/libs/heartbeat-backend-0.0.1-SNAPSHOT.jar
retention-days: ${{ vars.RETENTION_DAYS || 10 }}
build_frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '16.x'
- name: Install
run: |
npm install -g pnpm
pnpm install --no-frozen-lockfile
- name: Lint
run: pnpm run lint
- name: Build
run: |
pnpm run build
- uses: actions/upload-artifact@v4
with:
name: frontend-app
path: frontend/dist
retention-days: ${{ vars.RETENTION_DAYS || 10 }}
build_and_push_image:
runs-on: ubuntu-latest
needs:
- build_frontend
- build_backend
steps:
- uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Tag name
run: |
echo "TAG_NAME=$(git tag --sort version:refname | tail -n 1)" >> "$GITHUB_ENV"
- name: Build and Push Docker Image for frontend
uses: docker/build-push-action@v5
with:
file: ./ops/infra/Dockerfile.frontend
push: true
tags: |
ghcr.io/${{ env.LOWCASE_REPO_NAME }}_frontend:${{ env.TAG_NAME }}
ghcr.io/${{ env.LOWCASE_REPO_NAME }}_frontend:latest
- name: Build and Push Docker Image for backend
uses: docker/build-push-action@v5
with:
file: ./ops/infra/Dockerfile.backend
push: true
tags: |
ghcr.io/${{ env.LOWCASE_REPO_NAME }}_backend:${{ env.TAG_NAME }}
ghcr.io/${{ env.LOWCASE_REPO_NAME }}_backend:latest
build-sbom:
runs-on: ubuntu-latest
needs:
- build_and_push_image
steps:
- uses: actions/checkout@v4
- uses: anchore/sbom-action@v0
with:
path: ./
artifact-name: ${{ env.REPO_NAME }}.${{ env.TAG_NAME }}.sbom.spdx.json
- uses: anchore/sbom-action/publish-sbom@v0
release:
runs-on: ubuntu-latest
needs:
- build-sbom
steps:
- uses: actions/checkout@v4
- name: Download frontend artifact
uses: actions/download-artifact@v4
with:
name: frontend-app
path: ./${{ env.REPO_NAME }}-frontend
- name: Download backend artifact
uses: actions/download-artifact@v4
with:
name: backend-app
- name: List
run: |
ls -a
- name: Release
id: build
run: |
mkdir ${{ env.REPO_NAME }}
mv ./${{ env.REPO_NAME }}-frontend ${{ env.REPO_NAME }}
mv heartbeat-backend-0.0.1-SNAPSHOT.jar ${{ env.REPO_NAME }}
zip -r ${{ env.REPO_NAME }}-$(git tag --sort version:refname | tail -n 1).zip ${{ env.REPO_NAME }}
ls
echo "TAG_NAME=$(git tag --sort version:refname | tail -n 1)" >> "$GITHUB_ENV"
- name: Upload zip file
uses: softprops/action-gh-release@v2
with:
files: ${{ env.REPO_NAME }}-${{ env.TAG_NAME }}.zip