44 pull_request :
55 push :
66 branches : ["master", "main"]
7- tags :
7+ tags : ["*"]
88 workflow_dispatch :
9+ inputs :
10+ version :
11+ type : string
912
1013jobs :
1114 build :
@@ -23,19 +26,47 @@ jobs:
2326
2427 - name : Build
2528 id : build
26- run : |
27- nix build --accept-flake-config .#static
28- echo "name=$(nix derivation show ./result | jq -r .[].env.name)" >>"$GITHUB_OUTPUT"
29- echo "artifacts=$(find -L result -type f)" >>"$GITHUB_OUTPUT"
29+ run : nix build --accept-flake-config .#static
3030
31- - name : Record system details
32- id : system-details
31+ - name : Record result
32+ id : result
3333 run : |
34- echo "system=$(uname -s)" >>"$GITHUB_OUTPUT"
35- echo "machine=$(uname -m)" >>"$GITHUB_OUTPUT"
34+ derivation=$(nix derivation show ./result | jq -r .[].env.name)
35+ artifact=$derivation-$(uname -s)-$(uname -m)
36+ products=$(find -L result -type f)
37+ echo "artifact=$artifact" >>"$GITHUB_OUTPUT"
38+ echo "products=$products" >>"$GITHUB_OUTPUT"
3639
37- - name : Upload artifacts
40+ - name : Upload artifact
3841 uses : actions/upload-artifact@v4
3942 with :
40- name : ${{ steps.build.outputs.name }}-${{ steps.system-details.outputs.system }}-${{ steps.system-details.outputs.machine }}
41- path : ${{ steps.build.outputs.artifacts }}
43+ name : ${{ steps.result.outputs.artifact }}
44+ path : ${{ steps.result.outputs.products }}
45+
46+ - if : github.ref_type == 'tag' || inputs.version
47+ name : Create release content
48+ id : release
49+ run : |
50+ version='${{ github.ref_type == 'tag' && github.ref_name || inputs.version }}'
51+ release=${{ steps.result.outputs.artifact }}-$version
52+ archive=$release.tgz
53+ mkdir "$release" && cp -p ${{ steps.result.outputs.products }} "$release"
54+ tar -czf "$archive" "$release"
55+ notes=$release.md
56+ cat <<EOF >"$notes"
57+ See [CHANGELOG.md](${{ github.server_url }}/${{ github.repository }}/blob/main/CHANGELOG.md)
58+ EOF
59+ echo "version=$version" >>"$GITHUB_OUTPUT"
60+ echo "archive=$archive" >>"$GITHUB_OUTPUT"
61+ echo "notes=$notes" >>"$GITHUB_OUTPUT"
62+
63+ - if : steps.release.outputs.version
64+ name : Create release
65+ uses : softprops/action-gh-release@v2
66+ with :
67+ tag_name : ${{ steps.release.outputs.version }}
68+ files : ${{ steps.release.outputs.archive }}
69+ body_path : ${{ steps.release.outputs.notes }}
70+ target_commitish : ${{ github.sha }}
71+ fail_on_unmatched_files : true
72+ draft : true
0 commit comments