Skip to content

Commit 17f768b

Browse files
committed
Update release workflows to publish _compatibility plugin
commit-id:96b0213f
1 parent 96b931d commit 17f768b

File tree

7 files changed

+132
-29
lines changed

7 files changed

+132
-29
lines changed

.github/workflows/_build-plugin-binaries.yml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,20 @@ on:
1010
ref:
1111
required: false
1212
type: string
13+
plugin_name:
14+
required: true
15+
default: "snforge-scarb-plugin"
16+
type: string
1317
workflow_dispatch:
1418
inputs:
1519
# Specify the version in MAJOR.MINOR.PATCH format, without a leading 'v'
1620
overridden_plugin_version:
1721
required: false
1822
type: string
23+
plugin_name:
24+
required: true
25+
default: "snforge-scarb-plugin"
26+
type: string
1927

2028
jobs:
2129
build-binaries:
@@ -32,28 +40,28 @@ jobs:
3240
os: ubuntu-latest
3341
# Use cross to link oldest GLIBC possible.
3442
cross: true
35-
lib-name: "libsnforge_scarb_plugin"
43+
lib-name-prefix: "lib"
3644
ext: "so"
3745

3846
- target: aarch64-unknown-linux-gnu
3947
os: ubuntu-latest
4048
cross: true
41-
lib-name: "libsnforge_scarb_plugin"
49+
lib-name-prefix: "lib"
4250
ext: "so"
4351

4452
- target: x86_64-apple-darwin
4553
os: macos-latest
46-
lib-name: "libsnforge_scarb_plugin"
54+
lib-name-prefix: "lib"
4755
ext: "dylib"
4856

4957
- target: aarch64-apple-darwin
5058
os: macos-latest
51-
lib-name: "libsnforge_scarb_plugin"
59+
lib-name-prefix: "lib"
5260
ext: "dylib"
5361

5462
- target: x86_64-pc-windows-msvc
5563
os: windows-latest
56-
lib-name: "snforge_scarb_plugin"
64+
lib-name-prefix: ""
5765
ext: "dll"
5866

5967
# The scarb builds for following platforms are experimental and not officially supported by starknet-foundry.
@@ -98,7 +106,7 @@ jobs:
98106
echo "CARGO=cross" >> $GITHUB_ENV
99107
100108
- name: Build
101-
working-directory: crates/snforge-scarb-plugin
109+
working-directory: crates/${{ inputs.plugin_name }}
102110
run: ${{ env.CARGO }} build --release --locked --target ${{ matrix.target }}
103111

104112
- name: Rename Binary
@@ -108,22 +116,23 @@ jobs:
108116
109117
source scripts/handle_version.sh
110118
111-
PACKAGE_NAME="snforge_scarb_plugin"
119+
PACKAGE_NAME=${{ inputs.plugin_name }}
120+
PACKAGE_NAME=${PACKAGE_NAME//-/_} # Replace `-` with `_` in name
112121
PACKAGE_VERSION=$(get_version "${{ inputs.overridden_plugin_version }}")
113122
114123
TARGET="${{ matrix.target }}"
115124
EXT="${{ matrix.ext }}"
116-
LIB_NAME="${{ matrix.lib-name }}"
125+
LIB_NAME="${{ matrix.lib-name-prefix }}${PACKAGE_NAME}"
117126
118127
OUTPUT_BINARY="${PACKAGE_NAME}_v${PACKAGE_VERSION}_${TARGET}.${EXT}"
119128
120-
mv ./crates/snforge-scarb-plugin/target/${TARGET}/release/${LIB_NAME}.${EXT} ./crates/snforge-scarb-plugin/target/${TARGET}/release/${OUTPUT_BINARY}
129+
mv ./crates/${{ inputs.plugin_name }}/target/${TARGET}/release/${LIB_NAME}.${EXT} ./crates/${{ inputs.plugin_name }}/target/${TARGET}/release/${OUTPUT_BINARY}
121130
122-
echo "OUTPUT_BINARY_PATH=./crates/snforge-scarb-plugin/target/${TARGET}/release/${OUTPUT_BINARY}" >> $GITHUB_ENV
131+
echo "OUTPUT_plugin_name=./crates/${{ inputs.plugin_name }}/target/${TARGET}/release/${OUTPUT_BINARY}" >> $GITHUB_ENV
123132
124133
- name: Upload Artifact
125134
uses: actions/upload-artifact@v4
126135
with:
127-
name: build-plugin-${{ matrix.target }}
128-
path: ${{ env.OUTPUT_BINARY_PATH }}
136+
name: build-plugin-${{ inputs.plugin_name }}-${{ matrix.target }}
137+
path: ${{ env.OUTPUT_plugin_name }}
129138
compression-level: 0

.github/workflows/_publish-plugin.yml

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ on:
1010
overridden_plugin_version:
1111
required: false
1212
type: string
13+
plugin_name:
14+
required: true
15+
default: "${{ inputs.plugin_name }}"
16+
type: string
1317

1418
jobs:
1519
check-uploaded:
16-
name: Check snforge_scarb_plugin Version
20+
name: Check ${{ inputs.plugin_name }} Version
1721
runs-on: ubuntu-latest
1822
outputs:
1923
plugin_uploaded: ${{ steps.check-uploaded.outputs.plugin_uploaded }}
@@ -26,14 +30,16 @@ jobs:
2630
2731
source scripts/handle_version.sh
2832
29-
snforge_scarb_plugin_version=$(get_version "${{ inputs.overridden_plugin_version }}")
33+
plugin_underscores=${{ inputs.plugin_name }}
34+
plugin_underscores=${plugin_underscores//-/_}
35+
plugin_version=$(get_version "${{ inputs.overridden_plugin_version }}")
3036
3137
registry_url=${{ inputs.prod_registry == true && 'https://scarbs.xyz' || 'https://scarbs.dev' }}
32-
plugin_uploaded=$(curl -s ${registry_url}/api/v1/index/sn/fo/snforge_scarb_plugin.json | jq --arg version "$snforge_scarb_plugin_version" '[.[] | select(.v == $version)] | length > 0')
38+
plugin_uploaded=$(curl -s ${registry_url}/api/v1/index/sn/fo/${plugin_underscores}.json | jq --arg version "$plugin_version" '[.[] | select(.v == $version)] | length > 0')
3339
echo "plugin_uploaded=$plugin_uploaded" >> $GITHUB_OUTPUT
3440
3541
upload-to-registry:
36-
name: Upload snforge_scarb_plugin to the registry
42+
name: Upload ${{ inputs.plugin_name }} to the registry
3743
runs-on: ubuntu-latest
3844
needs: [check-uploaded]
3945
env:
@@ -54,27 +60,30 @@ jobs:
5460
- name: Unpack artifacts to target directory
5561
run: |
5662
set -euxo pipefail
57-
mkdir -p crates/snforge-scarb-plugin/target/scarb/cairo-plugin
5863
59-
mv artifacts-dl/build-plugin-*/snforge_scarb_plugin_v* crates/snforge-scarb-plugin/target/scarb/cairo-plugin/
64+
plugin_underscores=${{ inputs.plugin_name }}
65+
plugin_underscores=${plugin_underscores//-/_}
66+
67+
mkdir -p crates/${{ inputs.plugin_name }}/target/scarb/cairo-plugin
68+
mv artifacts-dl/build-plugin-*/${plugin_underscores}_v* crates/${{ inputs.plugin_name }}/target/scarb/cairo-plugin/
6069
6170
# Required for testing prebuild plugin while creating release.
6271
if [[ -n "${{ inputs.overridden_plugin_version }}" ]]; then
63-
cd crates/snforge-scarb-plugin/target/scarb/cairo-plugin/
72+
cd crates/${{ inputs.plugin_name }}/target/scarb/cairo-plugin/
6473
overridden_version="${{ inputs.overridden_plugin_version }}"
6574
66-
for file in snforge_scarb_plugin_v*; do
67-
if [[ -f "$file" && ! "$file" =~ "snforge_scarb_plugin_v${overridden_version}" ]]; then
68-
platform=$(echo "$file" | sed -E 's/snforge_scarb_plugin_v[0-9]+\.[0-9]+\.[0-9]+([-.].*)?_(.+)/\2/')
69-
new_file="snforge_scarb_plugin_v${overridden_version}_${platform}"
75+
for file in ${plugin_underscores}_v*; do
76+
if [[ -f "$file" && ! "$file" =~ "${plugin_underscores}_v${overridden_version}" ]]; then
77+
platform=$(echo "$file" | sed -E "s/${plugin_underscores}_v[0-9]+\.[0-9]+\.[0-9]+([-.].*)?_(.+)/\2/")
78+
new_file="${plugin_underscores}_v${overridden_version}_${platform}"
7079
mv "$file" "$new_file"
7180
fi
7281
done
7382
fi
7483
75-
- name: Publish snforge_scarb_plugin
84+
- name: Publish ${{ inputs.plugin_name }}
7685
if: needs.check-uploaded.outputs.plugin_uploaded == 'false' || github.event_name == 'workflow_dispatch'
77-
working-directory: crates/snforge-scarb-plugin
86+
working-directory: crates/${{ inputs.plugin_name }}
7887
run: |
7988
set -exo pipefail
8089
source ../../scripts/handle_version.sh

.github/workflows/nightly.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ jobs:
8282
with:
8383
overridden_plugin_version: ${{ needs.prepare.outputs.nightly_version }}
8484
ref: ${{ needs.prepare.outputs.nightly_branch }}
85+
plugin_name: "snforge-scarb-plugin"
86+
87+
build-compatibility-plugin-binaries:
88+
name: Build plugin binaries
89+
needs: prepare
90+
uses: ./.github/workflows/_build-plugin-binaries.yml
91+
with:
92+
overridden_plugin_version: ${{ needs.prepare.outputs.nightly_version }}
93+
ref: ${{ needs.prepare.outputs.nightly_branch }}
94+
plugin_name: "snforge-scarb-plugin-compatibility"
8595

8696
publish-plugin:
8797
needs: [ prepare, build-plugin-binaries ]
@@ -90,6 +100,18 @@ jobs:
90100
with:
91101
prod_registry: false
92102
overridden_plugin_version: ${{ needs.prepare.outputs.nightly_version }}
103+
plugin_name: "snforge-scarb-plugin"
104+
105+
106+
publish-compatibility-plugin:
107+
needs: [ prepare, build-plugin-binaries ]
108+
uses: ./.github/workflows/_publish-plugin.yml
109+
secrets: inherit
110+
with:
111+
prod_registry: false
112+
overridden_plugin_version: ${{ needs.prepare.outputs.nightly_version }}
113+
plugin_name: "snforge-scarb-plugin-compatibility"
114+
93115

94116
publish-std:
95117
needs: [ prepare, publish-plugin ]

.github/workflows/publish-plugin.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,18 @@ on:
1010
overridden_plugin_version:
1111
required: false
1212
type: string
13+
plugin_name:
14+
required: true
15+
default: "snforge-scarb-plugin"
16+
type: string
1317

1418
jobs:
1519
build-binaries:
1620
name: Build Plugin Binaries
1721
uses: ./.github/workflows/_build-plugin-binaries.yml
1822
with:
1923
overridden_plugin_version: ${{ inputs.overridden_plugin_version != '' && inputs.overridden_plugin_version || '' }}
24+
plugin_name: ${{ inputs.plugin_name }}
2025

2126
publish-plugin:
2227
name: Publish Plugin
@@ -25,4 +30,5 @@ jobs:
2530
with:
2631
prod_registry: ${{ inputs.prod_registry }}
2732
overridden_plugin_version: ${{ inputs.overridden_plugin_version != '' && inputs.overridden_plugin_version || '' }}
33+
plugin_name: '${{ inputs.plugin_name }}'
2834
secrets: inherit

.github/workflows/publish-std.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,19 @@ jobs:
7272
fi
7373
7474
scarb publish --allow-dirty ${{ inputs.prod_registry == true && ' ' || '--index https://scarbs.dev/' }}
75+
76+
- name: Publish snforge_std_compatibility
77+
working-directory: snforge_std_compatibility
78+
run: |
79+
source ../scripts/handle_version.sh
80+
81+
update_version_in_file "Scarb.toml" "${{ inputs.override_std_version }}"
82+
83+
if ${{ inputs.prod_registry == true }}; then
84+
scarb add snforge_scarb_plugin_compatibility@${{ inputs.plugin_dep_version }}
85+
else
86+
sed -i.bak "/snforge_scarb_plugin_compatibility/ s/\(snforge_scarb_plugin_compatibility = \).*/\1{ version = \"=${{ inputs.plugin_dep_version }}\", registry = \"https:\/\/scarbs.dev\/\" }/" Scarb.toml
87+
rm Scarb.toml.bak 2>/dev/null
88+
fi
89+
90+
scarb publish --allow-dirty ${{ inputs.prod_registry == true && ' ' || '--index https://scarbs.dev/' }}

.github/workflows/release.yml

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,37 @@ jobs:
6969
if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }}
7070
needs: verify-version
7171
uses: ./.github/workflows/_build-plugin-binaries.yml
72+
with:
73+
plugin_name: "snforge-scarb-plugin"
74+
75+
build-compatibility-plugin-binaries:
76+
name: Build compatibility plugin binaries
77+
if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }}
78+
needs: verify-version
79+
uses: ./.github/workflows/_build-plugin-binaries.yml
80+
with:
81+
plugin_name: "snforge-scarb-plugin-compatibility"
7282

7383
dev-publish-plugin:
74-
needs: [verify-version, build-binaries]
84+
needs: [verify-version, build-plugin-binaries]
7585
if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }}
7686
uses: ./.github/workflows/_publish-plugin.yml
7787
secrets: inherit
7888
with:
7989
overridden_plugin_version: ${{ needs.verify-version.outputs.version }}-test.${{ github.run_id }}
90+
plugin_name: "snforge-scarb-plugin"
91+
92+
dev-publish-compatibility-plugin:
93+
needs: [ verify-version, build-compatibility-plugin-binaries ]
94+
if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }}
95+
uses: ./.github/workflows/_publish-plugin.yml
96+
secrets: inherit
97+
with:
98+
overridden_plugin_version: ${{ needs.verify-version.outputs.version }}-test.${{ github.run_id }}
99+
plugin_name: "snforge-scarb-plugin-compatibility"
80100

81101
dev-publish-std:
82-
needs: [verify-version, dev-publish-plugin]
102+
needs: [verify-version, dev-publish-plugin, dev-publish-compatibility-plugin]
83103
if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }}
84104
uses: ./.github/workflows/publish-std.yml
85105
secrets: inherit
@@ -89,7 +109,7 @@ jobs:
89109

90110
test-binary:
91111
name: Test binary
92-
needs: [ build-binaries, verify-version, dev-publish-std]
112+
needs: [build-binaries, verify-version, dev-publish-std, dev-publish-plugin, dev-publish-compatibility-plugin]
93113
uses: ./.github/workflows/_test-binaries.yml
94114
secrets: inherit
95115
with:
@@ -138,10 +158,20 @@ jobs:
138158
secrets: inherit
139159
with:
140160
prod_registry: true
161+
plugin_name: "snforge-scarb-plugin"
162+
163+
publish-snforge-scarb-plugin-compatibility:
164+
name: Publish snforge_scarb_plugin_compatibility
165+
needs: [ test-binary, create-release ]
166+
uses: ./.github/workflows/_publish-plugin.yml
167+
secrets: inherit
168+
with:
169+
prod_registry: true
170+
plugin_name: "snforge-scarb-plugin-compatibility"
141171

142172
publish-to-registry:
143173
name: Publish packages to the registry
144-
needs: [ verify-version, publish-snforge-scarb-plugin ]
174+
needs: [ verify-version, publish-snforge-scarb-plugin, publish-snforge-scarb-plugin-compatibility ]
145175
uses: ./.github/workflows/publish-std.yml
146176
secrets: inherit
147177
with:

scripts/release.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ rm crates/snforge-scarb-plugin/Scarb.toml.bak 2> /dev/null
2222
sed -i.bak "/\[package\]/,/version =/ s/version = \".*/version = \"${VERSION}\"/" crates/snforge-scarb-plugin/Cargo.toml
2323
rm crates/snforge-scarb-plugin/Cargo.toml.bak 2> /dev/null
2424

25+
sed -i.bak "/\[package\]/,/version =/ s/version = \".*/version = \"${VERSION}\"/" snforge_std_compatibility/Scarb.toml
26+
rm snforge_std_compatibility/Scarb.toml.bak 2> /dev/null
27+
28+
sed -i.bak "/\[package\]/,/version =/ s/version = \".*/version = \"${VERSION}\"/" crates/snforge-scarb-plugin-compatibility/Scarb.toml
29+
rm crates/snforge-scarb-plugin-compatibility/Scarb.toml.bak 2> /dev/null
30+
31+
sed -i.bak "/\[package\]/,/version =/ s/version = \".*/version = \"${VERSION}\"/" crates/snforge-scarb-plugin-compatibility/Cargo.toml
32+
rm crates/snforge-scarb-plugin-compatibility/Cargo.toml.bak 2> /dev/null
33+
2534
# start: Update cache test data
2635
VERSION_UNDERSCORED=$(echo "$VERSION" | tr '.' '_')
2736

@@ -36,6 +45,8 @@ rm "$NEW_FILE_PATH.bak" 2> /dev/null
3645
# end
3746

3847
scarb --manifest-path snforge_std/Scarb.toml build
48+
scarb --manifest-path snforge_std_compatibility/Scarb.toml build
3949

4050
cargo update
4151
cargo update --manifest-path crates/snforge-scarb-plugin/Cargo.toml
52+
cargo update --manifest-path crates/snforge-scarb-plugin-compatibility/Cargo.toml

0 commit comments

Comments
 (0)