-
Notifications
You must be signed in to change notification settings - Fork 206
135 lines (120 loc) · 4.47 KB
/
release-macros.yml
File metadata and controls
135 lines (120 loc) · 4.47 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
# Dojo Cairo Macros release workflow.
#
name: release-macros
on:
workflow_dispatch:
pull_request:
types: [closed]
branches:
- main
env:
CARGO_TERM_COLOR: always
RUST_VERSION: 1.88.0
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}
jobs:
prepare:
if: (github.event.pull_request.merged == true && github.event.pull_request.head.ref == 'prepare-release-macros') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.release_info.outputs.tag_name }}
steps:
- uses: actions/checkout@v4
- name: Get version
id: release_info
run: |
cargo install cargo-get
echo "tag_name=v$(cargo get workspace.package.version)" >> $GITHUB_OUTPUT
build-artifacts:
name: ${{ matrix.job.target }} (${{ matrix.job.os }})
needs: prepare
runs-on: ${{ matrix.job.os }}
env:
PLATFORM_NAME: ${{ matrix.job.platform }}
TARGET: ${{ matrix.job.target }}
ARCH: ${{ matrix.job.arch }}
strategy:
matrix:
job:
- os: ubuntu-latest-8-cores
platform: linux
target: x86_64-unknown-linux-gnu
arch: amd64
- os: ubuntu-latest-8-cores-arm64
platform: linux
target: aarch64-unknown-linux-gnu
arch: arm64
svm_target_platform: linux-aarch64
- os: macos-latest-xlarge
platform: darwin
target: x86_64-apple-darwin
arch: amd64
- os: macos-latest
platform: darwin
target: aarch64-apple-darwin
arch: arm64
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
name: Rust Toolchain Setup
with:
targets: ${{ matrix.job.target }}
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true
- name: Build and archive binaries for the Dojo Cairo Macros
id: artifacts
run: |
cd ./crates/dojo/macros
cargo build --release --locked --target "${TARGET}"
ls -la ./target/"${TARGET}"/release
VERSION_NAME=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[0].version')
echo "version_name=${VERSION_NAME}"
# Determine library extension based on platform
if [ "$PLATFORM_NAME" == "linux" ]; then
DLL_EXT="so"
LIBRARY_NAME="dojo_cairo_macros_v${VERSION_NAME}_${TARGET}.${DLL_EXT}"
mv "./target/${TARGET}/release/libdojo_cairo_macros.${DLL_EXT}" "../../../${LIBRARY_NAME}"
echo "file_name=${LIBRARY_NAME}" >> $GITHUB_OUTPUT
elif [ "$PLATFORM_NAME" == "darwin" ]; then
DLL_EXT="dylib"
LIBRARY_NAME="dojo_cairo_macros_v${VERSION_NAME}_${TARGET}.${DLL_EXT}"
mv "./target/${TARGET}/release/libdojo_cairo_macros.${DLL_EXT}" "../../../${LIBRARY_NAME}"
echo "file_name=${LIBRARY_NAME}" >> $GITHUB_OUTPUT
else
# Error with unsupported platform, to prevent one from adding
# a platform to the matrix without adding the corresponding logic.
echo "Error: Unsupported platform: $PLATFORM_NAME"
exit 1
fi
shell: bash
- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-${{ matrix.job.target }}
path: ${{ steps.artifacts.outputs.file_name }}
retention-days: 1
publish-scarb-plugin:
runs-on: ubuntu-latest
needs: [build-artifacts]
steps:
- uses: actions/checkout@v4
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: "2.13.1"
- uses: actions/download-artifact@v4
with:
pattern: artifacts-*
path: artifacts
merge-multiple: true
- name: Extract libraries and publish to Scarb registry
run: |
# Create the target directory required by Scarb publish command
# to include pre-built binaries.
# https://docs.swmansion.com/scarb/docs/reference/procedural-macro.html#prebuilt-procedural-macros
mkdir -p ./crates/dojo/macros/target/scarb/cairo-plugin
for file in artifacts/*; do
cp "$file" ./crates/dojo/macros/target/scarb/cairo-plugin/
done
cd ./crates/dojo/macros
SCARB_REGISTRY_AUTH_TOKEN=${{ secrets.SCARB_REGISTRY_AUTH_TOKEN }} scarb publish --allow-dirty