-
Notifications
You must be signed in to change notification settings - Fork 11
116 lines (99 loc) · 3.63 KB
/
release.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
name: Release
on:
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:
jobs:
update:
name: Update
runs-on: ubuntu-latest
outputs:
nix_release: ${{ steps.update.outputs.nix_release }}
updated: ${{ steps.update.outputs.updated }}
steps:
- uses: cachix/install-nix-action@V27
with:
nix_path: nixpkgs=channel:nixpkgs-unstable
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure git
run: |
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
- name: Update from latest Hydra eval
id: update
run: ./update.rb
- name: Push release tag
if: steps.update.outputs.updated == 'true'
env:
NIX_RELEASE: ${{ steps.update.outputs.nix_release }}
run: |
[ -n "$NIX_RELEASE" ] || (echo 'NIX_RELEASE empty or undefined' >&2; exit 1)
git tag "$NIX_RELEASE"
git push origin "$NIX_RELEASE"
- name: Create release
if: steps.update.outputs.updated == 'true'
uses: actions/github-script@v7
env:
NIX_RELEASE: ${{ steps.update.outputs.nix_release }}
with:
script: await require('.ci/create-prerelease.js')({require, context, core, github});
test:
name: Test
needs: [update]
if: needs.update.outputs.updated == 'true'
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: cachix/install-nix-action@V27
with:
install_url: ${{ github.server_url }}/${{ github.repository }}/releases/download/${{ needs.update.outputs.nix_release }}/install
nix_path: nixpkgs=channel:nixpkgs-unstable
- name: Run nix-info
run: |
nix run nixpkgs#nix-info -- -m
- name: Pull container image
if: runner.os == 'Linux'
env:
NIX_RELEASE: ${{ needs.update.outputs.nix_release }}
run: |
[ -n "$NIX_RELEASE" ] || (echo 'NIX_RELEASE empty or undefined' >&2; exit 1)
curl -sfL "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/$NIX_RELEASE/$NIX_RELEASE-$(uname -m)-linux-container.tar.gz" |
docker load --quiet
- name: Run nix-info in container image
if: runner.os == 'Linux'
env:
NIX_RELEASE: ${{ needs.update.outputs.nix_release }}
GITHUB_TOKEN: ${{ github.token }}
run: |
docker run --rm -e GITHUB_TOKEN "nix:${NIX_RELEASE#nix-}" \
sh -c 'echo "access-tokens = github.com=$GITHUB_TOKEN" >> /etc/nix/nix.conf && \
nix --extra-experimental-features "nix-command flakes" run nixpkgs#nix-info -- -m'
release:
name: Release
needs: [update, test]
if: needs.update.outputs.updated == 'true' && startsWith(github.ref, 'refs/heads/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Combine and push images to GitHub Container Registry
env:
NIX_RELEASE: ${{ needs.update.outputs.nix_release }}
run: .ci/push-containers.sh
- name: Mark full release
uses: actions/github-script@v7
env:
NIX_RELEASE: ${{ needs.update.outputs.nix_release }}
with:
script: await require('.ci/mark-release.js')({require, context, core, github});