Repository navigation
109 lines (94 loc) · 3.36 KB
/
Copy pathci.yml
File metadata and controls
109 lines (94 loc) · 3.36 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
108
109
name: CI
on:
push:
branches:
- main
pull_request: {}
workflow_dispatch:
inputs:
tag:
description: >-
Version tag to push the package with, e.g. v0.1.0. Leave empty to
push a dev version derived from git metadata. To cut a release, run
this workflow against the release tag (e.g. v0.1.0) with this set to
the same value.
type: string
required: false
default: ""
# Cancel in-progress runs for the same PR. Runs on main are never cancelled.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
jobs:
check:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v31
with:
extra_nix_config: log-lines = 500
# Cache Nix store paths in the GitHub Actions cache so builds reuse work
# across runs. use-flakehub is off so artifacts stay in the Actions cache
# rather than going to a third party, which matters for a private repo.
- name: Cache Nix store
uses: DeterminateSystems/magic-nix-cache-action@908b263ff629f4cc17666315b7fd3ec127c6244d # v14
with:
use-flakehub: false
- name: Check
run: nix flake check --print-build-logs
# Pushes the package on every push to main and on any manual run. Both push a
# dev version derived from git metadata unless the run supplies a tag input,
# which is how releases are cut - see CONTRIBUTING.md.
push-package:
if: >-
(github.event_name == 'push' && github.ref == 'refs/heads/main')
|| github.event_name == 'workflow_dispatch'
needs: [check]
runs-on: ubuntu-24.04
steps:
# Building and pushing the package needs more disk than the runner has
# free by default, so reclaim space we don't use.
- name: Cleanup Disk
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
with:
android: true
dotnet: true
haskell: true
tool-cache: true
swap-storage: false
large-packages: false
docker-images: false
- name: Checkout
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v31
with:
extra_nix_config: log-lines = 500
# See the check job for why use-flakehub is off.
- name: Cache Nix store
uses: DeterminateSystems/magic-nix-cache-action@908b263ff629f4cc17666315b7fd3ec127c6244d # v14
with:
use-flakehub: false
# The Crossplane CLI uses Docker's credential store for OCI pushes.
- name: Login to registry
uses: docker/login-action@v3
with:
registry: xpkg.upbound.io
username: ${{ secrets.UP_ROBOT_ID }}
password: ${{ secrets.UP_ROBOT_TOKEN }}
# With a tag input (a release) push that exact version; otherwise push a
# dev version the push app derives from git metadata.
- name: Build and Push
run: |
nix run .#build --print-build-logs
if [ -n "${TAG}" ]; then
nix run .#push --print-build-logs -- --tag "${TAG}"
else
nix run .#push --print-build-logs
fi
env:
TAG: ${{ inputs.tag }}