-
Notifications
You must be signed in to change notification settings - Fork 90
119 lines (102 loc) · 3.33 KB
/
FNOS.yml
File metadata and controls
119 lines (102 loc) · 3.33 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
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
name: FNOS
on:
workflow_dispatch:
push:
branches:
- latest
paths:
- fn_version
jobs:
build-frontend:
runs-on: ubuntu-latest
steps:
- name: Checkout frontend code
uses: actions/checkout@v3
with:
repository: dongshull/Docker-Copilot-React
path: './frontend'
ref: 'master'
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: |
frontend/package-lock.json
frontend/package.json
- name: Build Frontend
run: |
cd frontend
npm ci
npm run build
- name: Upload Frontend Artifacts
uses: actions/upload-artifact@v4
with:
name: my-artifact-front-dist
path: frontend/dist
build-backend:
needs: [ build-frontend ]
runs-on: ubuntu-latest
strategy:
matrix:
arch: [ amd64, arm64 ]
steps:
- name: Checkout code back end
uses: actions/checkout@v3
- name: Download Frontend Artifacts
uses: actions/download-artifact@v4
with:
pattern: my-artifact-front-*
merge-multiple: true
path: front
- run: ls -R front
- name: Get version from file
id: get_version
run: |
echo "version=$(cat fn_version)" >> $GITHUB_ENV
- name: Cache Go Modules
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/msaber-back/pkg/mod
key: go-mod-${{ hashFiles('**/go.sum') }}
restore-keys: |
go-mod-
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23.4'
cache: false
- name: Build for ${{ matrix.arch }}
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=${{ matrix.arch }} go build -a --trimpath -ldflags="-w -s -X 'github.com/onlyLTY/dockerCopilot/internal/config.Version=${{ env.version }}' -X 'github.com/onlyLTY/dockerCopilot/internal/config.BuildDate=$(date)'" -o dist/linux/${{ matrix.arch }}/dockerCopilot-new .
- name: Compress binary
run: |
tar -czvf dockerCopilot-${{ matrix.arch }}.tar.gz dist/linux/${{ matrix.arch }}/dockerCopilot-new
- name: List current directory
run: ls -la
- name: Check if release already exists
id: check_release
run: |
exists=$(gh release view ${{ env.version }} 2>&1 | grep "release not found" || true)
if [[ -z "$exists" ]]; then
echo "Release exists"
echo "RELEASE_EXISTS=true" >> $GITHUB_ENV
else
echo "Release does not exist"
echo "RELEASE_EXISTS=false" >> $GITHUB_ENV
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release if not exists
if: env.RELEASE_EXISTS == 'false'
run: |
gh release create ${{ env.version }} \
--title "${{ env.version }}" \
--notes "Release of version ${{ env.version }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Asset for ${{ matrix.arch }}
run: |
gh release upload ${{ env.version }} dockerCopilot-${{ matrix.arch }}.tar.gz
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}