Skip to content

Commit dd254fb

Browse files
committed
ci: add nightly build
1 parent 1245f21 commit dd254fb

File tree

3 files changed

+88
-22
lines changed

3 files changed

+88
-22
lines changed

.github/workflows/ci.yaml

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ on: [push]
44

55
jobs:
66
build:
7-
environment: env
87
runs-on: ubuntu-latest
98
steps:
10-
- uses: nixbuild/nix-quick-install-action@v30
9+
- uses: actions/checkout@v3
10+
- name: Install Nix
11+
uses: cachix/install-nix-action@v17
1112
with:
12-
nix_conf: |
13-
keep-env-derivations = true
14-
keep-outputs = true
13+
extra_nix_config: |
14+
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
15+
1516
- name: Restore and save Nix store
1617
uses: nix-community/cache-nix-action@v6
1718
with:
@@ -35,20 +36,7 @@ jobs:
3536
# except any version with the key that is the same as the `primary-key`
3637
purge-primary-key: never
3738

38-
- uses: actions/checkout@v3
39-
- name: Install Nix
40-
uses: cachix/install-nix-action@v17
41-
with:
42-
extra_nix_config: |
43-
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
44-
45-
- name: Set git name
46-
run: git config --global user.name "cerulean-ci"
47-
48-
- name: Set git email
49-
run: git config --global user.email "[email protected]"
50-
5139
- name: Running Tests
5240
shell: 'nix develop .#ci -c bash -e {0}'
53-
run: make test-all
41+
run: make ci-test-all
5442

.github/workflows/nightly.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: nightly build
2+
3+
on:
4+
schedule:
5+
- cron: "30 01 * * *"
6+
jobs:
7+
nightly_release:
8+
environment: env
9+
name: nightly release
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Install Nix
14+
uses: cachix/install-nix-action@v17
15+
with:
16+
extra_nix_config: |
17+
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
18+
19+
- name: Restore and save Nix store
20+
uses: nix-community/cache-nix-action@v6
21+
with:
22+
# restore and save a cache using this key
23+
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
24+
# if there's no cache hit, restore a cache by this prefix
25+
restore-prefixes-first-match: nix-${{ runner.os }}-
26+
# collect garbage until the Nix store size (in bytes) is at most this number
27+
# before trying to save a new cache
28+
# 1G = 1073741824
29+
gc-max-store-size-linux: 1G
30+
# do purge caches
31+
purge: true
32+
# purge all versions of the cache
33+
purge-prefixes: nix-${{ runner.os }}-
34+
# created more than this number of seconds ago
35+
purge-created: 0
36+
# or last accessed this duration (ISO 8601 duration format)
37+
# before the start of the `Post Restore and save Nix store` phase
38+
purge-last-accessed: P1DT12H
39+
# except any version with the key that is the same as the `primary-key`
40+
purge-primary-key: never
41+
42+
- uses: actions/checkout@v6
43+
with:
44+
ref: master
45+
46+
- name: release
47+
run: make ci-release-nightly

Makefile

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
MAKEFLAGS += --always-make
22
DOCKER_USERNAME = coruscation
3+
VERSION_FILE = .cerulean-version
34

45
git-add-all:
56
git add ./
@@ -31,9 +32,14 @@ define with-secrets
3132
env env $$(gpg --batch --decrypt --passphrase $$CERULEAN_PASSPHRASE ./secrets.gpg | xargs) $(MAKE) $1
3233
endef
3334

34-
docker-publish-impl: docker-build-and-load
35-
docker login -u ${DOCKER_USERNAME} -p $${DOCKER_TOKEN}
36-
docker push ${DOCKER_USERNAME}/cerulean
35+
docker-publish-impl: # docker-build-and-load
36+
docker login -u ${DOCKER_USERNAME} -p $${DOCKER_TOKEN}; \
37+
docker push ${DOCKER_USERNAME}/cerulean; \
38+
cerulean_version="$$(cat $(VERSION_FILE))"; \
39+
if test -n "$${cerulean_version}"; then \
40+
docker image tag cerulean:latest ${DOCKER_USERNAME}/cerulean:"$${cerulean_version}"; \
41+
docker push ${DOCKER_USERNAME}/cerulean:"$${cerulean_version}"; \
42+
fi; \
3743

3844
docker-publish:
3945
$(call with-secrets,docker-publish-impl)
@@ -66,3 +72,28 @@ clj-deps-update:
6672
neil dep update
6773

6874
update-dependencies: | npm-update clj-deps-update nix-deps-lock nix-npm-deps-lock
75+
76+
ci-init:
77+
git config --global user.name "cerulean-ci"
78+
git config --global user.email "[email protected]"
79+
80+
prepare-release-version:
81+
echo $$(date -u +"%Y-%m-%dT%H.%M.%S") > $(VERSION_FILE)
82+
git add $(VERSION_FILE)
83+
84+
release: | test-all
85+
$(MAKE) docker-publish
86+
87+
release-if-necessary:
88+
if test -n "$$(git rev-list --after='24 hours' HEAD)"; then \
89+
echo "release"; \
90+
$(MAKE) release;\
91+
else \
92+
echo "last commit committed before 24 hours, do not release"; \
93+
fi \
94+
95+
ci-release-nightly: | ci-init prepare-release-version
96+
$(MAKE) release-if-necessary
97+
98+
ci-test-all: | ci-init
99+
$(MAKE) test-all

0 commit comments

Comments
 (0)