Skip to content

Commit 396fb70

Browse files
authored
Merge branch 'Unleash:main' into resolve_all
2 parents d79268e + 7ef9751 commit 396fb70

File tree

9 files changed

+210
-319
lines changed

9 files changed

+210
-319
lines changed

.github/workflows/build-binaries.yaml

Lines changed: 0 additions & 146 deletions
This file was deleted.
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
name: Release FFI and Upload Binaries
2+
3+
on:
4+
push:
5+
tags:
6+
- yggdrasilffi-v*
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: "New semver version (e.g. 0.2.0)"
11+
required: true
12+
type: string
13+
14+
jobs:
15+
create-tag-and-release:
16+
name: Create Tag and GitHub Release
17+
if: github.event_name == 'workflow_dispatch'
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write
21+
22+
outputs:
23+
full_tag: ${{ steps.tag.outputs.full_tag }}
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Set up Git
32+
run: |
33+
git config user.name "github-actions[bot]"
34+
git config user.email "github-actions[bot]@users.noreply.github.com"
35+
36+
- name: Set full tag name
37+
id: tag
38+
run: |
39+
FULL_TAG="yggdrasilffi-v${{ inputs.tag }}"
40+
echo "full_tag=$FULL_TAG" >> "$GITHUB_OUTPUT"
41+
42+
- name: Get latest matching tag
43+
id: latest_tag
44+
run: |
45+
LATEST_TAG=$(git tag --list 'yggdrasilffi-v*' --sort=-creatordate | grep -v "^${{ steps.tag.outputs.full_tag }}$" | head -n 1 || echo "")
46+
echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT
47+
48+
- name: Create annotated tag
49+
run: |
50+
git tag -a "${{ steps.tag.outputs.full_tag }}" -m "Release ${{ steps.tag.outputs.full_tag }}"
51+
git push origin "${{ steps.tag.outputs.full_tag }}"
52+
53+
- name: Generate changelog with git-cliff
54+
id: changelog
55+
run: |
56+
cargo install git-cliff
57+
58+
if [[ "${{ steps.latest_tag.outputs.latest_tag }}" != "" ]]; then
59+
CHANGELOG=$(git cliff --tag "${{ steps.tag.outputs.full_tag }}" --range "${{ steps.latest_tag.outputs.latest_tag }}..HEAD" --strip all)
60+
else
61+
CHANGELOG=$(git cliff --tag "${{ steps.tag.outputs.full_tag }}" --strip all)
62+
fi
63+
64+
echo 'changelog<<EOF' >> $GITHUB_OUTPUT
65+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
66+
echo 'EOF' >> $GITHUB_OUTPUT
67+
68+
- name: Create GitHub release
69+
uses: softprops/action-gh-release@v2
70+
with:
71+
tag_name: ${{ steps.tag.outputs.full_tag }}
72+
name: Release ${{ steps.tag.outputs.full_tag }}
73+
body: ${{ steps.changelog.outputs.changelog }}
74+
75+
build-and-upload:
76+
name: Build + Upload Binaries
77+
needs: [create-tag-and-release]
78+
runs-on: ${{ matrix.os }}
79+
strategy:
80+
matrix:
81+
include:
82+
- os: ubuntu-latest
83+
target: x86_64-unknown-linux-gnu
84+
output: libyggdrasilffi.so
85+
name: libyggdrasilffi_x86_64.so
86+
cross: true
87+
- os: ubuntu-latest
88+
target: aarch64-unknown-linux-gnu
89+
output: libyggdrasilffi.so
90+
name: libyggdrasilffi_arm64.so
91+
cross: true
92+
- os: ubuntu-latest
93+
target: x86_64-unknown-linux-musl
94+
output: libyggdrasilffi.so
95+
name: libyggdrasilffi_x86_64-musl.so
96+
cross: true
97+
- os: ubuntu-latest
98+
target: aarch64-unknown-linux-musl
99+
output: libyggdrasilffi.so
100+
name: libyggdrasilffi_arm64-musl.so
101+
cross: true
102+
- os: windows-latest
103+
target: x86_64-pc-windows-gnu
104+
output: yggdrasilffi.dll
105+
name: yggdrasilffi_x86_64.dll
106+
cross: false
107+
- os: windows-latest
108+
target: aarch64-pc-windows-msvc
109+
output: yggdrasilffi.dll
110+
name: yggdrasilffi_arm64.dll
111+
cross: true
112+
- os: windows-latest
113+
target: i686-pc-windows-msvc
114+
output: yggdrasilffi.dll
115+
name: yggdrasilffi_i686.dll
116+
cross: true
117+
- os: macos-13
118+
target: x86_64-apple-darwin
119+
output: libyggdrasilffi.dylib
120+
name: libyggdrasilffi_x86_64.dylib
121+
- os: macos-latest
122+
target: aarch64-apple-darwin
123+
output: libyggdrasilffi.dylib
124+
name: libyggdrasilffi_arm64.dylib
125+
cross: true
126+
127+
steps:
128+
- uses: actions/checkout@v4
129+
130+
- name: Install cross (if needed)
131+
if: ${{ matrix.cross == true }}
132+
run: cargo install cross
133+
134+
- name: Install rust
135+
run: |
136+
rustup set auto-self-update disable
137+
rustup toolchain install stable --profile default
138+
rustup show
139+
140+
- name: Rust cache
141+
uses: Swatinem/rust-cache@v2
142+
143+
- name: Build Rust Library (Cross)
144+
if: ${{ matrix.cross == true }}
145+
run: |
146+
rustup target add ${{ matrix.target }}
147+
cross build -p yggdrasilffi --release --target ${{ matrix.target }};
148+
149+
- name: Build Rust Library (Cargo)
150+
if: ${{ matrix.cross == false }}
151+
run: cargo build -p yggdrasilffi --release --target ${{ matrix.target }};
152+
153+
- name: Rename Output Binary
154+
run: |
155+
mv target/${{ matrix.target }}/release/${{ matrix.output }} target/${{ matrix.target }}/release/${{ matrix.name }}
156+
157+
- name: Set Tag Name
158+
id: tag
159+
run: |
160+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
161+
echo "tag=${{ needs.create-tag-and-release.outputs.full_tag }}" >> $GITHUB_ENV
162+
else
163+
echo "tag=${GITHUB_REF##*/}" >> $GITHUB_ENV
164+
echo "tag=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
165+
fi
166+
167+
- name: Get Release Upload URL by Tag
168+
id: get_release
169+
uses: actions/github-script@v5
170+
with:
171+
script: |
172+
const tag = process.env.tag;
173+
console.log(`Looking for release with tag: ${tag}`);
174+
const { data: releases } = await github.rest.repos.listReleases({
175+
owner: context.repo.owner,
176+
repo: context.repo.repo,
177+
});
178+
const release = releases.find(r => r.tag_name === tag);
179+
if (release) {
180+
core.setOutput("upload_url", release.upload_url);
181+
} else {
182+
throw new Error(`Release with tag ${tag} not found.`);
183+
}
184+
result-encoding: json
185+
186+
- name: Upload Binary to Release
187+
if: ${{ steps.get_release.outputs.upload_url }}
188+
uses: actions/upload-release-asset@v1
189+
with:
190+
upload_url: ${{ steps.get_release.outputs.upload_url }}
191+
asset_path: target/${{ matrix.target }}/release/${{ matrix.name }}
192+
asset_name: "${{ matrix.name }}"
193+
asset_content_type: application/octet-stream
194+
env:
195+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)