-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
107 lines (107 loc) · 3.76 KB
/
.gitlab-ci.yml
File metadata and controls
107 lines (107 loc) · 3.76 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
stages:
- feature-check
- staging-build
- staging-upload
- production-build
- production-upload
- production-release
.nix-base:
image: nixos/nix:latest
variables:
GIT_DEPTH: 0
before_script:
- export NIX_CONFIG="experimental-features = nix-command flakes"
- nix develop .#stg -c cachix use musikell
feature-check:
extends: .nix-base
stage: feature-check
script:
- echo "[MUSIKELL::feature-check] Running checks and generating coverage data..."
- nix develop .#stg -c ./utils/run-check.sh stg
- |
nix develop .#stg -c hpc report \
result/coverage/hpc/vanilla/tix/musikell-test/musikell-test.tix \
--hpcdir=result/coverage/hpc/vanilla/mix/musikell \
--hpcdir=result/coverage/hpc/vanilla/mix/musikell-test \
--exclude=Main
- mkdir -p coverage
- cp -r result/coverage/hpc/vanilla/html/musikell-test coverage/
coverage: '/(\d+\.?\d*)% expressions used/'
artifacts:
paths:
- coverage/
expire_in: 1 week
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
staging-build:
extends: .nix-base
stage: staging-build
script:
- echo "[MUSIKELL::staging-branch] Building binary for staging..."
- nix develop .#stg -c ./utils/run-check.sh stg
- nix build .# --out-link result
- nix develop .#stg -c cachix push musikell result
- echo "[MUSIKELL::staging-branch] Build successful. Preparing artifacts..."
- mkdir -p artifacts/bin
- cp result/bin/musikell artifacts/bin/
artifacts:
paths:
- artifacts/bin/
rules:
- if: $CI_COMMIT_BRANCH == "staging"
staging-upload:
extends: .nix-base
stage: staging-upload
needs: [staging-build]
script:
- |
echo "[MUSIKELL::staging-branch] Uploading ./artifacts/bin/musikell to Supabase as musikell-${CI_COMMIT_SHORT_SHA}"
nix develop .#stg -c \
curl -X POST \
--header "Authorization: Bearer ${SUPABASE_SERVICE_ROLE_KEY}" \
--header "Content-Type: application/octet-stream" \
--header "x-upsert: true" \
--data-binary "@artifacts/bin/musikell" \
"https://gkajuwzghjlrdpojnbwh.supabase.co/storage/v1/object/musikell/musikell-${CI_COMMIT_SHORT_SHA}"
echo "[MUSIKELL::staging-branch] Uploaded musikell-${CI_COMMIT_SHORT_SHA}"
rules:
- if: $CI_COMMIT_BRANCH == "staging"
production-build:
extends: .nix-base
stage: production-build
script:
- echo "[MUSIKELL::production-release] Building binary for version $CI_COMMIT_TAG..."
- nix develop .#stg -c ./utils/run-check.sh stg
- nix build .# --out-link result
- nix develop .#stg -c cachix push musikell result
- echo "[MUSIKELL::production-release] Build successful. Preparing artifacts..."
- mkdir -p artifacts/bin
- cp result/bin/musikell artifacts/bin/
artifacts:
paths:
- artifacts/bin/
rules:
- if: $CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"
production-upload:
extends: .nix-base
stage: production-upload
needs: [production-build]
script:
- |
nix develop .#stg -c \
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
--upload-file artifacts/bin/musikell \
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/musikell/${CI_COMMIT_TAG}/musikell"
rules:
- if: $CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"
production-release:
extends: .nix-base
stage: production-release
needs: [production-upload]
script:
- |
nix develop .#stg -c \
release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \
--assets-link "{\"name\":\"musikell\",\"url\":\"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/musikell/${CI_COMMIT_TAG}/musikell\"}"
rules:
- if: $CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"