-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
73 lines (67 loc) · 2.5 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
stages:
- Build
- Upload
- Release
build:
stage: Build
image: node:20
before_script:
- npm install --legacy-peer-deps
script:
- test "$CI_COMMIT_BRANCH" == "master" && echo "Creating Latest" || (node -e "const { writeFileSync } = require('fs'); const p = require('./package.json'); p.version = p.version + '-dev'; writeFileSync('package.json', JSON.stringify(p));" && echo "Creating Dev")
- export VERSION=$(node -e "console.log(require('./package.json').version)")
- echo "VERSION=$VERSION" >> variables.env
- export APPNAME=$(node -e "console.log(require('./package.json').build.productName)")
- echo "APPNAME=$APPNAME" >> variables.env
- echo "APPNAME_LOWER=$(echo $APPNAME | tr '[:upper:]' '[:lower:]')" >> variables.env
- npm run pack
artifacts:
reports:
dotenv: variables.env
name: $CI_COMMIT_REF_SLUG
paths:
- $CI_PROJECT_DIR/dist/*.*
when: on_success
only:
- master
- dev
variables:
LINUX_BINARY: '${APPNAME}-${VERSION}.AppImage'
LINUX_INSTALLER: '${APPNAME_LOWER}_${VERSION}_amd64.deb'
PACKAGE_REGISTRY_URL: '${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${APPNAME}/${VERSION}'
PACKAGE_REGISTRY_URL_YML: '${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${APPNAME}'
upload:
stage: Upload
needs:
- job: build
artifacts: true
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "dev"
when: on_success
script:
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" -L --upload-file "./dist/${LINUX_BINARY}" "${PACKAGE_REGISTRY_URL}/${LINUX_BINARY}" && \
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" -L --upload-file "./dist/${LINUX_INSTALLER}" "${PACKAGE_REGISTRY_URL}/${LINUX_INSTALLER}" \
auto-release:
image: registry.gitlab.com/gitlab-org/release-cli
needs:
- job: build
artifacts: true
- job: upload
artifacts: true
stage: Release
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == "master"
when: on_success
script:
- echo "Release $VERSION"
- |
release-cli --server-url https://git.ibaraki.app \
create --name "Release $VERSION" --tag-name v$VERSION \
--description 'Ibaraki Group' --ref $CI_COMMIT_SHA \
--assets-link "{\"name\":\"${APPNAME} Linux AppImage\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_BINARY}\"}" \
--assets-link "{\"name\":\"${APPNAME} Linux DEB\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_INSTALLER}\"}" \