Skip to content

Commit 2a5743a

Browse files
committed
ci: create release of bundles
1 parent 1a7b7a4 commit 2a5743a

File tree

1 file changed

+133
-0
lines changed

1 file changed

+133
-0
lines changed

.github/workflows/release.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: Release Build and Publish
2+
3+
permissions:
4+
contents: write
5+
pull-requests: read
6+
7+
on:
8+
push:
9+
tags:
10+
- "v*"
11+
pull_request:
12+
paths:
13+
- "**/*.rs"
14+
- "**/Cargo.toml"
15+
- "Cargo.lock"
16+
- "flake.nix"
17+
workflow_dispatch:
18+
inputs:
19+
release_name:
20+
description: "Name of release (optional)"
21+
required: false
22+
default: ""
23+
create_release:
24+
description: "Create a GitHub release? (true/false)"
25+
required: false
26+
default: "false"
27+
28+
jobs:
29+
generate-matrix:
30+
runs-on: ubuntu-latest
31+
outputs:
32+
matrix: ${{ steps.generate-matrix.outputs.matrix }}
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Install Nix
37+
uses: cachix/install-nix-action@v30
38+
with:
39+
nix_path: nixpkgs=channel:nixos-unstable
40+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
41+
extra_nix_config: |
42+
experimental-features = nix-command flakes
43+
44+
- name: Generate matrix
45+
id: generate-matrix
46+
run: |
47+
MATRIX=$(nix run .#matrix --quiet)
48+
echo "Generated Matrix:"
49+
echo "$MATRIX"
50+
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
51+
52+
build:
53+
runs-on: ubuntu-latest
54+
needs: generate-matrix
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
include: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
59+
env:
60+
ARTIFACT_NAME: ""
61+
VERSION: ${{ github.event.inputs.release_name || github.ref_name }}
62+
63+
steps:
64+
- uses: actions/checkout@v4
65+
66+
- name: Install Nix
67+
uses: cachix/install-nix-action@v30
68+
with:
69+
nix_path: nixpkgs=channel:nixos-unstable
70+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
71+
extra_nix_config: |
72+
experimental-features = nix-command flakes
73+
74+
- name: Set up artifact name
75+
run: |
76+
echo "ARTIFACT_NAME=grhooks_${{ env.VERSION }}_${{ matrix.os }}_${{ matrix.arch }}.${{ matrix.format }}" >> $GITHUB_ENV
77+
78+
- name: Build package
79+
run: |
80+
echo "Building ${{ matrix.package }} for ${{ matrix.arch }}-${{ matrix.os }}..."
81+
nix bundle --bundler "${{ matrix.bundler }}" ".#${{ matrix.package }}" --out-link result
82+
83+
mkdir -p dist
84+
cp result/*${{ matrix.format }} dist/${{ env.ARTIFACT_NAME }}
85+
86+
- name: Upload Artifact
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: ${{ env.ARTIFACT_NAME }}
90+
path: dist/*
91+
92+
create-release:
93+
runs-on: ubuntu-latest
94+
needs: build
95+
if: ${{ github.event.inputs.create_release == 'true' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) }}
96+
steps:
97+
- uses: actions/checkout@v4
98+
99+
- name: Generate changelog
100+
uses: orhun/git-cliff-action@v4
101+
id: git-cliff
102+
with:
103+
config: cliff.toml
104+
args: --latest
105+
env:
106+
OUTPUT: CHANGES.md
107+
GITHUB_REPO: ${{ github.repository }}
108+
109+
- name: Get release name
110+
id: release_name
111+
run: |
112+
if [ -n "${{ github.event.inputs.release_name }}" ]; then
113+
echo "RELEASE_NAME=${{ github.event.inputs.release_name }}" >> $GITHUB_OUTPUT
114+
else
115+
echo "RELEASE_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
116+
fi
117+
118+
- name: Download Artifacts
119+
uses: actions/download-artifact@v4
120+
with:
121+
path: artifacts
122+
123+
- name: Create Release
124+
uses: softprops/action-gh-release@v2
125+
with:
126+
make_latest: true
127+
prerelease: ${{ steps.release_name.outputs.release_name != '' && contains(steps.release_name.outputs.release_name, 'a') }}
128+
tag_name: ${{ steps.release_name.outputs.release_name }}
129+
name: ${{ steps.release_name.outputs.release_name }}
130+
body: ${{ steps.git-cliff.outputs.content }}
131+
files: |
132+
artifacts/*
133+
CHANGES.md

0 commit comments

Comments
 (0)