Skip to content

Commit 2bea547

Browse files
committed
Update release workflows to publish _compatibility plugin
Closes #3144 commit-id:96b0213f
1 parent 3879197 commit 2bea547

File tree

8 files changed

+132
-38
lines changed

8 files changed

+132
-38
lines changed

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@ on:
1010
ref:
1111
required: false
1212
type: string
13+
plugin_name:
14+
required: true
15+
type: string
1316
workflow_dispatch:
1417
inputs:
1518
# Specify the version in MAJOR.MINOR.PATCH format, without a leading 'v'
1619
overridden_plugin_version:
1720
required: false
1821
type: string
22+
plugin_name:
23+
required: true
24+
type: string
1925

2026
jobs:
2127
build-binaries:
@@ -32,23 +38,23 @@ jobs:
3238
os: ubuntu-latest
3339
# Use cross to link oldest GLIBC possible.
3440
cross: true
35-
lib-name: "libsnforge_scarb_plugin"
41+
lib-name-prefix: "lib"
3642
ext: "so"
3743

3844
- target: aarch64-unknown-linux-gnu
3945
os: ubuntu-latest
4046
cross: true
41-
lib-name: "libsnforge_scarb_plugin"
47+
lib-name-prefix: "lib"
4248
ext: "so"
4349

4450
- target: x86_64-apple-darwin
4551
os: macos-latest
46-
lib-name: "libsnforge_scarb_plugin"
52+
lib-name-prefix: "lib"
4753
ext: "dylib"
4854

4955
- target: aarch64-apple-darwin
5056
os: macos-latest
51-
lib-name: "libsnforge_scarb_plugin"
57+
lib-name-prefix: "lib"
5258
ext: "dylib"
5359

5460
# The scarb builds for following platforms are experimental and not officially supported by starknet-foundry.
@@ -93,7 +99,7 @@ jobs:
9399
echo "CARGO=cross" >> $GITHUB_ENV
94100
95101
- name: Build
96-
working-directory: crates/snforge-scarb-plugin
102+
working-directory: crates/${{ inputs.plugin_name }}
97103
run: ${{ env.CARGO }} build --release --locked --target ${{ matrix.target }}
98104

99105
- name: Rename Binary
@@ -103,22 +109,23 @@ jobs:
103109
104110
source scripts/handle_version.sh
105111
106-
PACKAGE_NAME="snforge_scarb_plugin"
112+
PACKAGE_NAME=${{ inputs.plugin_name }}
113+
PACKAGE_NAME=${PACKAGE_NAME//-/_} # Replace `-` with `_` in name
107114
PACKAGE_VERSION=$(get_version "${{ inputs.overridden_plugin_version }}")
108115
109116
TARGET="${{ matrix.target }}"
110117
EXT="${{ matrix.ext }}"
111-
LIB_NAME="${{ matrix.lib-name }}"
118+
LIB_NAME="${{ matrix.lib-name-prefix }}${PACKAGE_NAME}"
112119
113120
OUTPUT_BINARY="${PACKAGE_NAME}_v${PACKAGE_VERSION}_${TARGET}.${EXT}"
114121
115-
mv ./crates/snforge-scarb-plugin/target/${TARGET}/release/${LIB_NAME}.${EXT} ./crates/snforge-scarb-plugin/target/${TARGET}/release/${OUTPUT_BINARY}
122+
mv ./crates/${{ inputs.plugin_name }}/target/${TARGET}/release/${LIB_NAME}.${EXT} ./crates/${{ inputs.plugin_name }}/target/${TARGET}/release/${OUTPUT_BINARY}
116123
117-
echo "OUTPUT_BINARY_PATH=./crates/snforge-scarb-plugin/target/${TARGET}/release/${OUTPUT_BINARY}" >> $GITHUB_ENV
124+
echo "OUTPUT_BINARY_PATH=./crates/${{ inputs.plugin_name }}/target/${TARGET}/release/${OUTPUT_BINARY}" >> $GITHUB_ENV
118125
119126
- name: Upload Artifact
120127
uses: actions/upload-artifact@v4
121128
with:
122-
name: build-plugin-${{ matrix.target }}
129+
name: build-${{ inputs.plugin_name }}-${{ matrix.target }}
123130
path: ${{ env.OUTPUT_BINARY_PATH }}
124131
compression-level: 0

.github/workflows/_publish-plugin.yml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ on:
1010
overridden_plugin_version:
1111
required: false
1212
type: string
13+
plugin_name:
14+
required: true
15+
type: string
1316

1417
jobs:
1518
check-uploaded:
16-
name: Check snforge_scarb_plugin Version
19+
name: Check ${{ inputs.plugin_name }} Version
1720
runs-on: ubuntu-latest
1821
outputs:
1922
plugin_uploaded: ${{ steps.check-uploaded.outputs.plugin_uploaded }}
@@ -26,14 +29,16 @@ jobs:
2629
2730
source scripts/handle_version.sh
2831
29-
snforge_scarb_plugin_version=$(get_version "${{ inputs.overridden_plugin_version }}")
32+
plugin_name_underscores=${{ inputs.plugin_name }}
33+
plugin_name_underscores=${plugin_name_underscores//-/_}
34+
plugin_version=$(get_version "${{ inputs.overridden_plugin_version }}")
3035
3136
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')
37+
plugin_uploaded=$(curl -s ${registry_url}/api/v1/index/sn/fo/${plugin_name_underscores}.json | jq --arg version "$plugin_version" '[.[] | select(.v == $version)] | length > 0')
3338
echo "plugin_uploaded=$plugin_uploaded" >> $GITHUB_OUTPUT
3439
3540
upload-to-registry:
36-
name: Upload snforge_scarb_plugin to the registry
41+
name: Upload ${{ inputs.plugin_name }} to the registry
3742
runs-on: ubuntu-latest
3843
needs: [check-uploaded]
3944
env:
@@ -42,9 +47,6 @@ jobs:
4247
- uses: actions/checkout@v4
4348
- uses: dtolnay/rust-toolchain@stable
4449
- uses: software-mansion/setup-scarb@v1
45-
with:
46-
# TODO(#3144) Remove
47-
scarb-version: "2.11.4"
4850

4951
- name: Download artifacts
5052
uses: actions/download-artifact@v4
@@ -54,27 +56,30 @@ jobs:
5456
- name: Unpack artifacts to target directory
5557
run: |
5658
set -euxo pipefail
57-
mkdir -p crates/snforge-scarb-plugin/target/scarb/cairo-plugin
5859
59-
mv artifacts-dl/build-plugin-*/snforge_scarb_plugin_v* crates/snforge-scarb-plugin/target/scarb/cairo-plugin/
60+
plugin_name_underscores=${{ inputs.plugin_name }}
61+
plugin_name_underscores=${plugin_name_underscores//-/_}
62+
63+
mkdir -p crates/${{ inputs.plugin_name }}/target/scarb/cairo-plugin
64+
mv artifacts-dl/build-*/${plugin_name_underscores}_v* crates/${{ inputs.plugin_name }}/target/scarb/cairo-plugin/
6065
6166
# Required for testing prebuild plugin while creating release.
6267
if [[ -n "${{ inputs.overridden_plugin_version }}" ]]; then
63-
cd crates/snforge-scarb-plugin/target/scarb/cairo-plugin/
68+
cd crates/${{ inputs.plugin_name }}/target/scarb/cairo-plugin/
6469
overridden_version="${{ inputs.overridden_plugin_version }}"
6570
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}"
71+
for file in ${plugin_name_underscores}_v*; do
72+
if [[ -f "$file" && ! "$file" =~ "${plugin_name_underscores}_v${overridden_version}" ]]; then
73+
platform=$(echo "$file" | sed -E "s/${plugin_name_underscores}_v[0-9]+\.[0-9]+\.[0-9]+([-.].*)?_(.+)/\2/")
74+
new_file="${plugin_name_underscores}_v${overridden_version}_${platform}"
7075
mv "$file" "$new_file"
7176
fi
7277
done
7378
fi
7479
75-
- name: Publish snforge_scarb_plugin
80+
- name: Publish ${{ inputs.plugin_name }}
7681
if: needs.check-uploaded.outputs.plugin_uploaded == 'false' || github.event_name == 'workflow_dispatch'
77-
working-directory: crates/snforge-scarb-plugin
82+
working-directory: crates/${{ inputs.plugin_name }}
7883
run: |
7984
set -exo pipefail
8085
source ../../scripts/handle_version.sh

.github/workflows/_test-binaries.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ jobs:
3030
steps:
3131
- uses: actions/checkout@v4
3232
- uses: software-mansion/setup-scarb@v1
33-
with:
34-
# TODO(#3144) Remove
35-
scarb-version: "2.11.0"
3633

3734
- name: Setup rust
3835
run: |

.github/workflows/nightly.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,18 @@ 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+
# This job is not necessary for nightly releases, but we still publish compatibility plugin for
89+
# the sake of consistency with the normal release workflow.
90+
name: Build compatibility plugin binaries
91+
needs: prepare
92+
uses: ./.github/workflows/_build-plugin-binaries.yml
93+
with:
94+
overridden_plugin_version: ${{ needs.prepare.outputs.nightly_version }}
95+
ref: ${{ needs.prepare.outputs.nightly_branch }}
96+
plugin_name: "snforge-scarb-plugin-compatibility"
8597

8698
publish-plugin:
8799
needs: [ prepare, build-plugin-binaries ]
@@ -90,9 +102,23 @@ jobs:
90102
with:
91103
prod_registry: false
92104
overridden_plugin_version: ${{ needs.prepare.outputs.nightly_version }}
105+
plugin_name: "snforge-scarb-plugin"
106+
107+
108+
publish-compatibility-plugin:
109+
# This job is not necessary for nightly releases, but we still publish compatibility plugin for
110+
# the sake of consistency with the normal release workflow.
111+
needs: [ prepare, build-compatibility-plugin-binaries ]
112+
uses: ./.github/workflows/_publish-plugin.yml
113+
secrets: inherit
114+
with:
115+
prod_registry: false
116+
overridden_plugin_version: ${{ needs.prepare.outputs.nightly_version }}
117+
plugin_name: "snforge-scarb-plugin-compatibility"
118+
93119

94120
publish-std:
95-
needs: [ prepare, publish-plugin ]
121+
needs: [ prepare, publish-plugin, publish-compatibility-plugin ]
96122
uses: ./.github/workflows/publish-std.yml
97123
secrets: inherit
98124
with:
@@ -102,7 +128,7 @@ jobs:
102128

103129
test-binary:
104130
name: Test binary
105-
needs: [ prepare, build-binaries, build-plugin-binaries, publish-plugin, publish-std]
131+
needs: [ prepare, build-binaries, build-plugin-binaries, publish-plugin, publish-compatibility-plugin, publish-std ]
106132
uses: ./.github/workflows/_test-binaries.yml
107133
secrets: inherit
108134
with:

.github/workflows/publish-plugin.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ on:
1010
overridden_plugin_version:
1111
required: false
1212
type: string
13+
plugin_name:
14+
required: true
15+
type: string
1316

1417
jobs:
1518
build-binaries:
1619
name: Build Plugin Binaries
1720
uses: ./.github/workflows/_build-plugin-binaries.yml
1821
with:
1922
overridden_plugin_version: ${{ inputs.overridden_plugin_version != '' && inputs.overridden_plugin_version || '' }}
23+
plugin_name: ${{ inputs.plugin_name }}
2024

2125
publish-plugin:
2226
name: Publish Plugin
@@ -25,4 +29,5 @@ jobs:
2529
with:
2630
prod_registry: ${{ inputs.prod_registry }}
2731
overridden_plugin_version: ${{ inputs.overridden_plugin_version != '' && inputs.overridden_plugin_version || '' }}
32+
plugin_name: '${{ inputs.plugin_name }}'
2833
secrets: inherit

.github/workflows/publish-std.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ jobs:
4444
toolchain: stable
4545

4646
- uses: software-mansion/setup-scarb@v1
47-
with:
48-
# TODO(#3144) Remove
49-
scarb-version: "2.11.0"
5047

5148
- name: Publish sncast_std
5249
working-directory: sncast_std
@@ -72,3 +69,19 @@ jobs:
7269
fi
7370
7471
scarb publish --allow-dirty ${{ inputs.prod_registry == true && ' ' || '--index https://scarbs.dev/' }}
72+
73+
- name: Publish snforge_std_compatibility
74+
working-directory: snforge_std_compatibility
75+
run: |
76+
source ../scripts/handle_version.sh
77+
78+
update_version_in_file "Scarb.toml" "${{ inputs.override_std_version }}"
79+
80+
if ${{ inputs.prod_registry == true }}; then
81+
scarb add snforge_scarb_plugin_compatibility@${{ inputs.plugin_dep_version }}
82+
else
83+
sed -i.bak "/snforge_scarb_plugin_compatibility/ s/\(snforge_scarb_plugin_compatibility = \).*/\1{ version = \"=${{ inputs.plugin_dep_version }}\", registry = \"https:\/\/scarbs.dev\/\" }/" Scarb.toml
84+
rm Scarb.toml.bak 2>/dev/null
85+
fi
86+
87+
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)