Skip to content

Commit 4f6ec2b

Browse files
committed
Add an automated release workflow
1 parent f8d0b01 commit 4f6ec2b

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ["*"]
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
type: string
10+
11+
jobs:
12+
build:
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest, macos-latest]
16+
fail-fast: false
17+
18+
runs-on: ${{ matrix.os }}
19+
20+
steps:
21+
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Install nix
26+
uses: cachix/install-nix-action@v31
27+
with:
28+
nix_path: nixpkgs=channel:nixos-unstable
29+
30+
- name: Enable cachix
31+
uses: cachix/cachix-action@v16
32+
with:
33+
name: neil-mayhew
34+
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
35+
36+
- name: Build
37+
run: |
38+
type=${{ matrix.os == 'macos-latest' && 'dynamic' || 'static' }}
39+
nix build --accept-flake-config .#$type.ghc910
40+
41+
- name: Push to cachix
42+
run: |
43+
nix-store -qR --include-outputs $(nix-store -qd result) |
44+
grep -v '\.drv$' |
45+
cachix push neil-mayhew
46+
47+
- name: Create release archive
48+
id: result
49+
run: |
50+
derivation=$(nix derivation show ./result | jq -r .[].env.pname)
51+
version='${{ github.ref_type == 'tag' && github.ref_name || inputs.version }}'
52+
release=$derivation-$version
53+
sudo mkdir "$release" && sudo cp -p $(find -L result -type f) "$release"
54+
archive=$release-$(uname -s)-$(uname -m).tgz
55+
tar -czf "$archive" "$release"
56+
echo "archive=$archive" >>"$GITHUB_OUTPUT"
57+
58+
- name: Upload artifact
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: ${{ matrix.os }}
62+
path: ${{ steps.result.outputs.archive }}
63+
64+
release:
65+
needs: build
66+
67+
runs-on: ubuntu-latest
68+
69+
steps:
70+
71+
- name: Download artifacts
72+
uses: actions/download-artifact@v4
73+
with:
74+
merge-multiple: true
75+
76+
- name: Create release
77+
uses: softprops/action-gh-release@v2
78+
with:
79+
target_commitish: ${{ github.sha }}
80+
files: '*.tgz'
81+
fail_on_unmatched_files: true
82+
generate_release_notes: true

0 commit comments

Comments
 (0)