forked from yanranxiaoxi/OpenNav
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
153 lines (140 loc) · 4.38 KB
/
.gitlab-ci.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
153
stages:
- test
- build
- package
- upload
- deploy
- release
#########################
# Test #
#########################
prettier-test:
stage: test
tags:
- linuxdocker
image: node:latest
script:
- npm run ins:devnode
- npm run check
allow_failure: true
#########################
# Build #
#########################
npm-install:
stage: build
tags:
- linuxdocker
image: node:latest
rules:
- if: $CI_COMMIT_BRANCH == "main"
script:
- npm run ins:node
artifacts:
name: 'OpenNav-$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA'
paths:
- ./Public/node_modules/
composer-install:
stage: build
tags:
- linuxdocker
image: composer:2
rules:
- if: $CI_COMMIT_BRANCH == "main"
script:
- composer install --ignore-platform-req=ext-intl
artifacts:
name: 'OpenNav-$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA'
paths:
- ./vendor/
#########################
# Package #
#########################
package:
stage: package
tags:
- windowsserver2022powershell
rules:
- if: $CI_COMMIT_BRANCH == "main"
dependencies:
- npm-install
- composer-install
script:
- Invoke-WebRequest
-Uri "https://publicsuffix.org/list/public_suffix_list.dat"
-OutFile ".\Data\PublicSuffixList.dat";
- Set-Location ".\Public\";
- Move-Item ".\node_modules\" ".\node_modules_old\";
- ${nodeModulesDirArray} =
"clipboard\dist",
"font-awesome\css",
"font-awesome\fonts",
"font-awesome\less",
"jquery\dist",
"layui\dist";
- foreach (${nodeModulesDir} in ${nodeModulesDirArray}) {
New-Item -Path ".\node_modules\${nodeModulesDir}\" -ItemType Directory;
Move-Item ".\node_modules_old\${nodeModulesDir}\*" ".\node_modules\${nodeModulesDir}\";
}
- Remove-Item ".\node_modules_old\" -Recurse;
- PowerShell -Command "& {git clone --depth=1 https://gitlab.soraharu.com/XiaoXi/OpenNav-Material-Design.git .\themes\material-design\}";
- Set-Location ".\themes\material-design\";
- PowerShell -Command "& {npm run ins}";
- Set-Location "..\..\..\..\";
- if (Test-Path -Path ".\OpenNav-compiled.zip" -PathType Leaf) {
Remove-Item ".\OpenNav-compiled.zip" -Recurse;
}
- PowerShell -Command "& {7z a .\OpenNav-compiled.zip .\OpenNav\*}";
- PowerShell -Command "& {7z d .\OpenNav-compiled.zip *.git\ -r}";
- Move-Item ".\OpenNav-compiled.zip" ".\OpenNav\";
artifacts:
name: 'OpenNav-compiled-$CI_COMMIT_SHORT_SHA'
paths:
- ./OpenNav-compiled.zip
#########################
# Upload #
#########################
upload:
stage: upload
tags:
- windowsserver2022powershell
rules:
- if: $CI_COMMIT_TAG
dependencies:
- package
script:
- ${downloadServerRootDir} = "D:\wwwroot\downloadserver.soraharu.com\OpenNav\${CI_COMMIT_TAG}\";
- if (Test-Path -Path "${downloadServerRootDir}") {
Remove-Item "${downloadServerRootDir}*" -Recurse;
} else {
New-Item -Path "${downloadServerRootDir}" -ItemType Directory;
}
- Move-Item ".\OpenNav-compiled.zip" "${downloadServerRootDir}";
#########################
# Deploy #
#########################
deploy-xiaoxi:
stage: deploy
tags:
- windowsserver2022powershell
rules:
- if: $CI_COMMIT_TAG
dependencies:
- package
script:
- ${xiaoxiServerRootDir} = "D:\wwwroot\newtab.soraharu.com\";
- PowerShell -Command "& {7z x .\OpenNav-compiled.zip -o${xiaoxiServerRootDir} -aoa}";
#########################
# Release #
#########################
release:
stage: release
tags:
- linuxdocker
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: $CI_COMMIT_TAG
dependencies: []
script:
- |
release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \
--assets-link "{\"name\":\"OpenNav-compiled.zip\",\"url\":\"https://downloadserver.soraharu.com:7000/OpenNav/$CI_COMMIT_TAG/OpenNav-compiled.zip\",\"link_type\":\"package\"}"