forked from cattr-app/desktop-application
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
151 lines (141 loc) · 5.52 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
stages:
- build
- upload
- deploy
variables:
PACKAGE_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/binaries/"
build-linux:
stage: build
tags:
- linux
only:
- tags
image: node:fermium-slim
artifacts:
untracked: false
expire_in: 30 days
paths:
- "target/*.AppImage"
- "target/*.tar.gz"
- "target/*.deb"
- "target/latest-linux.yml"
before_script:
- apt update
- apt install -y build-essential python3 pkg-config libsecret-1-0 libsecret-1-dev ca-certificates openssh-client dpkg-dev dpkg-sig
- export RELEASE_VERSION=$(echo "${CI_COMMIT_TAG}" | sed 's/v//')
- yarn
- npm config set git-tag-version false
- npm version $RELEASE_VERSION
script:
- yarn build-production
- yarn package-linux
build-mac:
stage: build
tags:
- macos
only:
- tags
artifacts:
untracked: false
expire_in: 30 days
paths:
- "target/*.dmg"
- "target/latest-mac.yml"
before_script:
- source ~/.zshrc
- security unlock-keychain -p "$APPLE_CI_HOST_PASSWORD"
- export RELEASE_VERSION=$(echo "${CI_COMMIT_TAG}" | sed 's/v//')
- yarn
- npm config set git-tag-version false
- npm version $RELEASE_VERSION
script:
- yarn build-production
- yarn package-mac-unsigned
build-windows:
stage: build
tags:
- windows
only:
- tags
artifacts:
untracked: false
expire_in: 30 days
paths:
- "target/*.exe"
- "target/*.appx"
- "target/latest*.yml"
before_script:
- $RELEASE_VERSION=$CI_COMMIT_TAG -replace '^v', ''
- yarn
- npm config set git-tag-version false
- npm version $RELEASE_VERSION
script:
- yarn build-production
- yarn package-windows
upload:
stage: upload
only:
- tags
image: curlimages/curl:latest
before_script:
- export RELEASE_VERSION=$(echo "${CI_COMMIT_TAG}" | sed 's/v//')
script:
- 'cd target && find . -maxdepth 1 -type f | while read -r line; do curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "${line}" "${PACKAGE_URL}${RELEASE_VERSION}/${result}"; done'
release:
stage: deploy
only:
- tags
when: manual
image: registry.gitlab.com/gitlab-org/release-cli:latest
before_script:
- export RELEASE_VERSION=$(echo "${CI_COMMIT_TAG}" | sed 's/v//')
script:
- |
release-cli create --name $CI_COMMIT_TAG --tag-name $CI_COMMIT_TAG \
--assets-link "{\"name\":\"dmg\",\"filepath\":\"/dmg\",\"url\":\"${PACKAGE_URL}${RELEASE_VERSION}/Cattr.dmg\", \"link_type\":\"package\"}" \
--assets-link "{\"name\":\"exe\",\"filepath\":\"/exe\",\"url\":\"${PACKAGE_URL}${RELEASE_VERSION}/Cattr.exe\", \"link_type\":\"package\"}" \
--assets-link "{\"name\":\"nsis\",\"filepath\":\"/nsis\",\"url\":\"${PACKAGE_URL}${RELEASE_VERSION}/Cattr_Setup.exe\", \"link_type\":\"package\"}" \
--assets-link "{\"name\":\"appx\",\"filepath\":\"/appx\",\"url\":\"${PACKAGE_URL}${RELEASE_VERSION}/Cattr.appx\", \"link_type\":\"package\"}" \
--assets-link "{\"name\":\"tar\",\"filepath\":\"/tar\",\"url\":\"${PACKAGE_URL}${RELEASE_VERSION}/Cattr.tar.gz\", \"link_type\":\"package\"}" \
--assets-link "{\"name\":\"deb\",\"filepath\":\"/deb\",\"url\":\"${PACKAGE_URL}${RELEASE_VERSION}/Cattr.deb\", \"link_type\":\"package\"}" \
--assets-link "{\"name\":\"appimage\",\"filepath\":\"/appimage\",\"url\":\"${PACKAGE_URL}${RELEASE_VERSION}/Cattr.AppImage\", \"link_type\":\"package\"}" \
--assets-link "{\"name\":\"windows-yml\",\"filepath\":\"/latest.yml\",\"url\":\"${PACKAGE_URL}${RELEASE_VERSION}/latest.yml\", \"link_type\":\"other\"}" \
--assets-link "{\"name\":\"mac-yml\",\"filepath\":\"/latest-mac.yml\",\"url\":\"${PACKAGE_URL}${RELEASE_VERSION}/latest-mac.yml\", \"link_type\":\"other\"}" \
--assets-link "{\"name\":\"linux-yml\",\"filepath\":\"/latest-linux.yml\",\"url\":\"${PACKAGE_URL}${RELEASE_VERSION}/latest-linux.yml\", \"link_type\":\"other\"}"
deploy:
stage: deploy
only:
- tags
when: manual
environment:
name: production
url: https://dl.cattr.app
image: alpine:latest
before_script:
- apk add --no-cache openssh-client gnupg
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- eval $(ssh-agent -s)
- echo "$CI_SSH_KEY" | base64 -d | ssh-add
- gpg-agent --daemon
- echo -e "$DEB_SIGNING_KEY" | base64 -d | gpg --import
- RELEASE_VERSION=`(echo $CI_COMMIT_TAG | sed 's/^v//')`
script:
- ssh [email protected] mkdir -p "/srv/dl/desktop/$RELEASE_VERSION"
- cd target
- scp *.dmg "[email protected]:/srv/dl/desktop/$RELEASE_VERSION/"
- scp *.exe "[email protected]:/srv/dl/desktop/$RELEASE_VERSION/"
- scp *.tar.gz "[email protected]:/srv/dl/desktop/$RELEASE_VERSION/"
- scp *.AppImage "[email protected]:/srv/dl/desktop/$RELEASE_VERSION/"
- scp *.deb "[email protected]:/srv/dl/packages/deb/amd64/"
- cd manifests
- scp * [email protected]:/srv/dl/manifests/
after_script:
- ssh [email protected] "cd /srv/dl/packages/deb && apt-ftparchive --arch amd64 packages amd64 > Packages"
- ssh [email protected] "cd /srv/dl/packages/deb && apt-ftparchive release . > Release"
- scp "[email protected]:/srv/dl/packages/deb/Release" .
- gpg -abs -o Release.gpg Release
- gpg --clearsign -o InRelease Release
- scp Release.gpg "[email protected]:/srv/dl/packages/deb/"
- scp InRelease "[email protected]:/srv/dl/packages/deb/"