-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
89 lines (82 loc) · 3.13 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
variables:
REPO_NAME: gitlab.com/Arno500/plex-richpresence
LINUX_AMD64_BINARY: "plex-rich-presence_linux_amd64-${CI_COMMIT_TAG}"
WINDOWS_AMD64_BINARY: "plex-rich-presence_windows_amd64-${CI_COMMIT_TAG}.exe"
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/plex-rich-presence/${CI_COMMIT_TAG}"
# The problem is that to be able to use go get, one needs to put
# the repository in the $GOPATH. So for example if your gitlab domain
# is gitlab.com, and that your repository is namespace/project, and
# the default GOPATH being /go, then you'd need to have your
# repository in /go/src/gitlab.com/namespace/project
# Thus, making a symbolic link corrects this.
before_script:
- mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
- ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
- cd $GOPATH/src/$REPO_NAME
stages:
- build
- upload
- release
- trigger-autoupdate
compile-linux:
image: golang:1.21
allow_failure: false
stage: build
script:
- apt-get update && apt-get -y install gcc libgtk-3-dev libayatana-appindicator3-dev
- GOOS=linux GOARCH=amd64 go build -tags unix -ldflags "-s -w -X gitlab.com/Arno500/plex-richpresence/autoupdate.Version=${CI_COMMIT_TAG}" -o $CI_PROJECT_DIR/${LINUX_AMD64_BINARY}
artifacts:
paths:
- plex-rich-presence_linux_amd64-*
only:
- tags
compile-windows:
image: x1unix/go-mingw:1.21
allow_failure: false
stage: build
script:
- GOOS=windows GOARCH=amd64 go build -tags windows -ldflags "-s -w -extldflags '-static' -H=windowsgui -X gitlab.com/Arno500/plex-richpresence/autoupdate.Version=${CI_COMMIT_TAG}" -o ${WINDOWS_AMD64_BINARY}
artifacts:
paths:
- plex-rich-presence_windows_amd64*
only:
- tags
upload:
stage: upload
image: curlimages/curl:latest
before_script: []
script:
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file ${WINDOWS_AMD64_BINARY} ${PACKAGE_REGISTRY_URL}/${WINDOWS_AMD64_BINARY}
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file ${LINUX_AMD64_BINARY} ${PACKAGE_REGISTRY_URL}/${LINUX_AMD64_BINARY}
only:
- tags
release:
image: registry.gitlab.com/gitlab-org/release-cli
stage: release
before_script: []
script:
- |
release-cli create --name "Release ${CI_COMMIT_TAG}" --tag-name "${CI_COMMIT_TAG}" \
--assets-link "{\"name\":\"${WINDOWS_AMD64_BINARY}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${WINDOWS_AMD64_BINARY}\"}" \
--assets-link "{\"name\":\"${LINUX_AMD64_BINARY}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_AMD64_BINARY}\"}"
only:
- tags
trigger-autoupdate:
stage: trigger-autoupdate
image:
name: rclone/rclone:latest
entrypoint: [""]
before_script: []
script:
- |
echo -n "${CI_COMMIT_TAG}" > VERSION
- |
rclone config create scaleway s3 provider "Scaleway" env-auth "true" region "fr-par" endpoint "s3.fr-par.scw.cloud" acl "public-read" path-style true
- |
rclone copy ./VERSION scaleway:plex-rich-presence/
- |
rclone copy ./${WINDOWS_AMD64_BINARY} scaleway:plex-rich-presence/binaries && rclone copy ./${LINUX_AMD64_BINARY} scaleway:plex-rich-presence/binaries
only:
- tags