Repository navigation
142 lines (123 loc) · 3.97 KB
/
Copy pathrelease-dev.yaml
File metadata and controls
142 lines (123 loc) · 3.97 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: publish pre-release
on:
push:
branches:
- main
concurrency:
group: release-pre-release
# Do not cancel a run after it may have begun replacing release assets.
cancel-in-progress: false
jobs:
check-tag:
name: check for a version tag
runs-on: ubuntu-latest
outputs:
is_tagged: ${{ steps.check.outputs.is_tagged }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- id: check
name: Detect version tag
run: |
is_tagged=false
if [[ -n "$(git tag --points-at "$GITHUB_SHA" --list 'v*')" ]]; then
is_tagged=true
echo "$GITHUB_SHA has a version tag; the stable workflow will publish it"
fi
echo "is_tagged=$is_tagged" >> "$GITHUB_OUTPUT"
build:
name: build for ${{ matrix.package }}
needs: check-tag
if: needs.check-tag.outputs.is_tagged == 'false'
runs-on: ${{ matrix.runner }}
permissions:
contents: read
id-token: write
strategy:
matrix:
include:
- package: aarch64-linux
runner: ubuntu-24.04-arm
- package: x86_64-linux
runner: ubuntu-latest
- package: aarch64-darwin
runner: macos-latest
steps:
- uses: actions/checkout@v6
- name: Install Nix
uses: NixOS/nix-installer-action@main
- name: Setup SSH keys for private flake inputs
uses: webfactory/ssh-agent@v0.10.0
with:
ssh-private-key: ${{ secrets.NOIB3_NIX_JETTISON_SSH_KEY }}
# This uses the current pre-release, so don't let a broken one prevent us
# from publishing its fix.
- name: Setup Nix cache
uses: sub60/setup-cache@main
continue-on-error: true
- name: Build package
run: nix build --accept-flake-config ".#${{ matrix.package }}"
- name: Stage artifact
run: |
cp result/bin/cache-action "cache-action-${{ matrix.package }}"
gzip -9n "cache-action-${{ matrix.package }}"
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: cache-action-${{ matrix.package }}.gz
path: cache-action-${{ matrix.package }}.gz
if-no-files-found: error
release-dev:
name: publish pre-release
needs:
- check-tag
- build
if: needs.check-tag.outputs.is_tagged == 'false'
runs-on: ubuntu-latest
permissions:
contents: write
env:
RELEASE_TAG: pre-release
steps:
- name: Download artifacts
uses: actions/download-artifact@v8
with:
pattern: cache-action-*
path: dist
merge-multiple: true
- name: Create or update pre-release
env:
GH_TOKEN: ${{ github.token }}
run: |
if gh api \
"repos/$GITHUB_REPOSITORY/git/ref/tags/$RELEASE_TAG" \
>/dev/null 2>&1; then
gh api --method PATCH \
"repos/$GITHUB_REPOSITORY/git/refs/tags/$RELEASE_TAG" \
--raw-field sha="$GITHUB_SHA" \
--field force=true \
--silent
else
gh api --method POST \
"repos/$GITHUB_REPOSITORY/git/refs" \
--raw-field ref="refs/tags/$RELEASE_TAG" \
--raw-field sha="$GITHUB_SHA" \
--silent
fi
command=create
if gh release view "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
command=edit
fi
gh release "$command" "$RELEASE_TAG" \
--repo "$GITHUB_REPOSITORY" \
--title "$RELEASE_TAG" \
--notes "Pre-release for commit $GITHUB_SHA" \
--prerelease \
--latest=false \
--target "$GITHUB_SHA" \
--verify-tag
- name: Upload release artifacts
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload "$RELEASE_TAG" dist/* --clobber --repo "$GITHUB_REPOSITORY"