forked from kaleidawave/ezno
-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (119 loc) · 4.71 KB
/
github-release.yml
File metadata and controls
145 lines (119 loc) · 4.71 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
143
144
145
name: GitHub release
on:
workflow_dispatch:
inputs:
ezno-version:
description: "Semver for Ezno (CLI) to release on"
required: false
default: "latest"
env:
CACHE_PATHS: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
jobs:
get-build-info:
runs-on: ubuntu-latest
outputs:
LATEST_EZNO_VERSION: ${{ steps.get-version.outputs.LATEST_EZNO_VERSION }}
LATEST_EZNO_VERSION_DASH: ${{ steps.get-version.outputs.LATEST_EZNO_VERSION_DASH }}
SPONSORS: ${{ steps.get-sponsors-and-contributors.outputs.SPONSORS }}
CONTRIBUTORS: ${{ steps.get-sponsors-and-contributors.outputs.CONTRIBUTORS }}
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
- name: Get version
id: get-version
run: |
if [ ${{ inputs.ezno-version }} = 'latest' ]; then
echo "::group::Ezno tags"
git for-each-ref --sort=creatordate --format '%(refname:short)' 'refs/tags/release/ezno-[0-9]*'
echo "::endgroup::"
TAG=$(git for-each-ref --sort=creatordate --format '%(refname:short)' 'refs/tags/release/ezno-[0-9]*' | tail -n 1 | cut -c 14-)
echo "::notice::Releasing with found version $TAG"
echo "LATEST_EZNO_VERSION=${TAG}" >> "$GITHUB_OUTPUT"
echo "LATEST_EZNO_VERSION_DASH=${TAG//./-}" >> "$GITHUB_OUTPUT"
else
TAG="${{ inputs.ezno-version }}"
echo "::notice::Releasing with specific version $TAG"
echo "LATEST_EZNO_VERSION=${TAG}" >> "$GITHUB_OUTPUT"
echo "LATEST_EZNO_VERSION_DASH=${TAG//./-}" >> "$GITHUB_OUTPUT"
fi
- name: Get sponsors and contributors
id: get-sponsors-and-contributors
run: |
SQP='.data.user.sponsorshipsAsMaintainer.edges | map(.node.sponsor.name // .node.sponsor.login) | join(",")'
GQL_SQ='{ user(login: "kaleidawave") { sponsorshipsAsMaintainer(first: 100, activeOnly: false) { edges { node { sponsor { name, login } } } } } }'
SPONSORS=$(gh api graphql -f query="$GQL_SQ" -q "$SQP")
CQP='map(.author.name // .author.login) | unique | join(",")'
CONTRIBUTORS=$(gh pr list --state merged --json author | jq "$CQP" --raw-output)
echo "SPONSORS=$SPONSORS" >> "$GITHUB_OUTPUT"
echo "CONTRIBUTORS=$CONTRIBUTORS" >> "$GITHUB_OUTPUT"
echo "::notice::CONTRIBUTORS=$CONTRIBUTORS and SPONSORS=$SPONSORS"
shell: bash
env:
GH_TOKEN: ${{ github.token }}
build:
needs: [get-build-info]
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
include:
- os: windows-latest
platform-name: x86_64-pc-windows
executable-extension: ".exe"
- os: ubuntu-latest
platform-name: x86_64-unknown-linux
runs-on: ${{ matrix.os }}
env:
LEVEL: release
# Important that everything here works in all the above OSes!
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build binary
run: cargo build --release
env:
SPONSORS: ${{ needs.get-build-info.outputs.SPONSORS }}
CONTRIBUTORS: ${{ needs.get-build-info.outputs.CONTRIBUTORS }}
- name: Rename and move ${{ env.LEVEL }} assets
run: |
mkdir artifacts
mv "target/${{ env.LEVEL }}/ezno${{ matrix.executable-extension }}" "artifacts/ezno-${{ needs.get-build-info.outputs.LATEST_EZNO_VERSION_DASH }}-${{ matrix.platform-name }}${{ matrix.executable-extension }}"
- uses: actions/upload-artifact@v4
with:
name: build-artifacts-${{ matrix.os }}
path: artifacts/*
if-no-files-found: error
retention-days: 1
github-release:
needs: [build, get-build-info]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: build-artifacts
pattern: build-artifacts-*
merge-multiple: true
- name: Print artifacts
run: |
echo "::group::Build artifacts"
ls -R build-artifacts
echo "::endgroup::"
- name: GitHub release
uses: softprops/action-gh-release@v1
with:
name: "Ezno ${{ needs.get-build-info.outputs.LATEST_EZNO_VERSION }}"
tag_name: "release/ezno-${{ needs.get-build-info.outputs.LATEST_EZNO_VERSION }}"
body: "For @kaleidawave to update"
files: |
README.md
build-artifacts/*