Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions .github/workflows/_build-plugin-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ on:
ref:
required: false
type: string
plugin_name:
required: true
type: string
workflow_dispatch:
inputs:
# Specify the version in MAJOR.MINOR.PATCH format, without a leading 'v'
overridden_plugin_version:
required: false
type: string
plugin_name:
required: true
type: string

jobs:
build-binaries:
Expand All @@ -32,23 +38,23 @@ jobs:
os: ubuntu-latest
# Use cross to link oldest GLIBC possible.
cross: true
lib-name: "libsnforge_scarb_plugin"
lib-name-prefix: "lib"
ext: "so"

- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
cross: true
lib-name: "libsnforge_scarb_plugin"
lib-name-prefix: "lib"
ext: "so"

- target: x86_64-apple-darwin
os: macos-latest
lib-name: "libsnforge_scarb_plugin"
lib-name-prefix: "lib"
ext: "dylib"

- target: aarch64-apple-darwin
os: macos-latest
lib-name: "libsnforge_scarb_plugin"
lib-name-prefix: "lib"
ext: "dylib"

# The scarb builds for following platforms are experimental and not officially supported by starknet-foundry.
Expand Down Expand Up @@ -93,7 +99,7 @@ jobs:
echo "CARGO=cross" >> $GITHUB_ENV

- name: Build
working-directory: crates/snforge-scarb-plugin
working-directory: crates/${{ inputs.plugin_name }}
run: ${{ env.CARGO }} build --release --locked --target ${{ matrix.target }}

- name: Rename Binary
Expand All @@ -103,22 +109,23 @@ jobs:

source scripts/handle_version.sh

PACKAGE_NAME="snforge_scarb_plugin"
PACKAGE_NAME=${{ inputs.plugin_name }}
PACKAGE_NAME=${PACKAGE_NAME//-/_} # Replace `-` with `_` in name
PACKAGE_VERSION=$(get_version "${{ inputs.overridden_plugin_version }}")

TARGET="${{ matrix.target }}"
EXT="${{ matrix.ext }}"
LIB_NAME="${{ matrix.lib-name }}"
LIB_NAME="${{ matrix.lib-name-prefix }}${PACKAGE_NAME}"

OUTPUT_BINARY="${PACKAGE_NAME}_v${PACKAGE_VERSION}_${TARGET}.${EXT}"

mv ./crates/snforge-scarb-plugin/target/${TARGET}/release/${LIB_NAME}.${EXT} ./crates/snforge-scarb-plugin/target/${TARGET}/release/${OUTPUT_BINARY}
mv ./crates/${{ inputs.plugin_name }}/target/${TARGET}/release/${LIB_NAME}.${EXT} ./crates/${{ inputs.plugin_name }}/target/${TARGET}/release/${OUTPUT_BINARY}

echo "OUTPUT_BINARY_PATH=./crates/snforge-scarb-plugin/target/${TARGET}/release/${OUTPUT_BINARY}" >> $GITHUB_ENV
echo "OUTPUT_BINARY_PATH=./crates/${{ inputs.plugin_name }}/target/${TARGET}/release/${OUTPUT_BINARY}" >> $GITHUB_ENV

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: build-plugin-${{ matrix.target }}
name: build-${{ inputs.plugin_name }}-${{ matrix.target }}
path: ${{ env.OUTPUT_BINARY_PATH }}
compression-level: 0
37 changes: 21 additions & 16 deletions .github/workflows/_publish-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ on:
overridden_plugin_version:
required: false
type: string
plugin_name:
required: true
type: string

jobs:
check-uploaded:
name: Check snforge_scarb_plugin Version
name: Check ${{ inputs.plugin_name }} Version
runs-on: ubuntu-latest
outputs:
plugin_uploaded: ${{ steps.check-uploaded.outputs.plugin_uploaded }}
Expand All @@ -26,14 +29,16 @@ jobs:

source scripts/handle_version.sh

snforge_scarb_plugin_version=$(get_version "${{ inputs.overridden_plugin_version }}")
plugin_name_underscores=${{ inputs.plugin_name }}
plugin_name_underscores=${plugin_name_underscores//-/_}
plugin_version=$(get_version "${{ inputs.overridden_plugin_version }}")

registry_url=${{ inputs.prod_registry == true && 'https://scarbs.xyz' || 'https://scarbs.dev' }}
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')
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')
echo "plugin_uploaded=$plugin_uploaded" >> $GITHUB_OUTPUT

upload-to-registry:
name: Upload snforge_scarb_plugin to the registry
name: Upload ${{ inputs.plugin_name }} to the registry
runs-on: ubuntu-latest
needs: [check-uploaded]
env:
Expand All @@ -42,9 +47,6 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: software-mansion/setup-scarb@v1
with:
# TODO(#3144) Remove
scarb-version: "2.11.4"

- name: Download artifacts
uses: actions/download-artifact@v4
Expand All @@ -54,27 +56,30 @@ jobs:
- name: Unpack artifacts to target directory
run: |
set -euxo pipefail
mkdir -p crates/snforge-scarb-plugin/target/scarb/cairo-plugin

mv artifacts-dl/build-plugin-*/snforge_scarb_plugin_v* crates/snforge-scarb-plugin/target/scarb/cairo-plugin/
plugin_name_underscores=${{ inputs.plugin_name }}
plugin_name_underscores=${plugin_name_underscores//-/_}

mkdir -p crates/${{ inputs.plugin_name }}/target/scarb/cairo-plugin
mv artifacts-dl/build-*/${plugin_name_underscores}_v* crates/${{ inputs.plugin_name }}/target/scarb/cairo-plugin/

# Required for testing prebuild plugin while creating release.
if [[ -n "${{ inputs.overridden_plugin_version }}" ]]; then
cd crates/snforge-scarb-plugin/target/scarb/cairo-plugin/
cd crates/${{ inputs.plugin_name }}/target/scarb/cairo-plugin/
overridden_version="${{ inputs.overridden_plugin_version }}"

for file in snforge_scarb_plugin_v*; do
if [[ -f "$file" && ! "$file" =~ "snforge_scarb_plugin_v${overridden_version}" ]]; then
platform=$(echo "$file" | sed -E 's/snforge_scarb_plugin_v[0-9]+\.[0-9]+\.[0-9]+([-.].*)?_(.+)/\2/')
new_file="snforge_scarb_plugin_v${overridden_version}_${platform}"
for file in ${plugin_name_underscores}_v*; do
if [[ -f "$file" && ! "$file" =~ "${plugin_name_underscores}_v${overridden_version}" ]]; then
platform=$(echo "$file" | sed -E "s/${plugin_name_underscores}_v[0-9]+\.[0-9]+\.[0-9]+([-.].*)?_(.+)/\2/")
new_file="${plugin_name_underscores}_v${overridden_version}_${platform}"
mv "$file" "$new_file"
fi
done
fi

- name: Publish snforge_scarb_plugin
- name: Publish ${{ inputs.plugin_name }}
if: needs.check-uploaded.outputs.plugin_uploaded == 'false' || github.event_name == 'workflow_dispatch'
working-directory: crates/snforge-scarb-plugin
working-directory: crates/${{ inputs.plugin_name }}
run: |
set -exo pipefail
source ../../scripts/handle_version.sh
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/_test-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: software-mansion/setup-scarb@v1
with:
# TODO(#3144) Remove
scarb-version: "2.11.0"

- name: Setup rust
run: |
Expand Down
30 changes: 28 additions & 2 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ jobs:
with:
overridden_plugin_version: ${{ needs.prepare.outputs.nightly_version }}
ref: ${{ needs.prepare.outputs.nightly_branch }}
plugin_name: "snforge-scarb-plugin"

build-compatibility-plugin-binaries:
# This job is not necessary for nightly releases, but we still publish compatibility plugin for
# the sake of consistency with the normal release workflow.
name: Build compatibility plugin binaries
needs: prepare
uses: ./.github/workflows/_build-plugin-binaries.yml
with:
overridden_plugin_version: ${{ needs.prepare.outputs.nightly_version }}
ref: ${{ needs.prepare.outputs.nightly_branch }}
plugin_name: "snforge-scarb-plugin-compatibility"

publish-plugin:
needs: [ prepare, build-plugin-binaries ]
Expand All @@ -90,9 +102,23 @@ jobs:
with:
prod_registry: false
overridden_plugin_version: ${{ needs.prepare.outputs.nightly_version }}
plugin_name: "snforge-scarb-plugin"


publish-compatibility-plugin:
# This job is not necessary for nightly releases, but we still publish compatibility plugin for
# the sake of consistency with the normal release workflow.
needs: [ prepare, build-compatibility-plugin-binaries ]
uses: ./.github/workflows/_publish-plugin.yml
secrets: inherit
with:
prod_registry: false
overridden_plugin_version: ${{ needs.prepare.outputs.nightly_version }}
plugin_name: "snforge-scarb-plugin-compatibility"


publish-std:
needs: [ prepare, publish-plugin ]
needs: [ prepare, publish-plugin, publish-compatibility-plugin ]
uses: ./.github/workflows/publish-std.yml
secrets: inherit
with:
Expand All @@ -102,7 +128,7 @@ jobs:

test-binary:
name: Test binary
needs: [ prepare, build-binaries, build-plugin-binaries, publish-plugin, publish-std]
needs: [ prepare, build-binaries, build-plugin-binaries, publish-plugin, publish-compatibility-plugin, publish-std ]
uses: ./.github/workflows/_test-binaries.yml
secrets: inherit
with:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/publish-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ on:
overridden_plugin_version:
required: false
type: string
plugin_name:
required: true
type: string

jobs:
build-binaries:
name: Build Plugin Binaries
uses: ./.github/workflows/_build-plugin-binaries.yml
with:
overridden_plugin_version: ${{ inputs.overridden_plugin_version != '' && inputs.overridden_plugin_version || '' }}
plugin_name: ${{ inputs.plugin_name }}

publish-plugin:
name: Publish Plugin
Expand All @@ -25,4 +29,5 @@ jobs:
with:
prod_registry: ${{ inputs.prod_registry }}
overridden_plugin_version: ${{ inputs.overridden_plugin_version != '' && inputs.overridden_plugin_version || '' }}
plugin_name: '${{ inputs.plugin_name }}'
secrets: inherit
19 changes: 16 additions & 3 deletions .github/workflows/publish-std.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ jobs:
toolchain: stable

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

- name: Publish sncast_std
working-directory: sncast_std
Expand All @@ -72,3 +69,19 @@ jobs:
fi

scarb publish --allow-dirty ${{ inputs.prod_registry == true && ' ' || '--index https://scarbs.dev/' }}

- name: Publish snforge_std_compatibility
working-directory: snforge_std_compatibility
run: |
source ../scripts/handle_version.sh

update_version_in_file "Scarb.toml" "${{ inputs.override_std_version }}"

if ${{ inputs.prod_registry == true }}; then
scarb add snforge_scarb_plugin_compatibility@${{ inputs.plugin_dep_version }}
else
sed -i.bak "/snforge_scarb_plugin_compatibility/ s/\(snforge_scarb_plugin_compatibility = \).*/\1{ version = \"=${{ inputs.plugin_dep_version }}\", registry = \"https:\/\/scarbs.dev\/\" }/" Scarb.toml
rm Scarb.toml.bak 2>/dev/null
fi

scarb publish --allow-dirty ${{ inputs.prod_registry == true && ' ' || '--index https://scarbs.dev/' }}
38 changes: 34 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,37 @@ jobs:
if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }}
needs: verify-version
uses: ./.github/workflows/_build-plugin-binaries.yml
with:
plugin_name: "snforge-scarb-plugin"

build-compatibility-plugin-binaries:
name: Build compatibility plugin binaries
if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }}
needs: verify-version
uses: ./.github/workflows/_build-plugin-binaries.yml
with:
plugin_name: "snforge-scarb-plugin-compatibility"

dev-publish-plugin:
needs: [verify-version, build-binaries]
needs: [verify-version, build-plugin-binaries]
if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }}
uses: ./.github/workflows/_publish-plugin.yml
secrets: inherit
with:
overridden_plugin_version: ${{ needs.verify-version.outputs.version }}-test.${{ github.run_id }}
plugin_name: "snforge-scarb-plugin"

dev-publish-compatibility-plugin:
needs: [ verify-version, build-compatibility-plugin-binaries ]
if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }}
uses: ./.github/workflows/_publish-plugin.yml
secrets: inherit
with:
overridden_plugin_version: ${{ needs.verify-version.outputs.version }}-test.${{ github.run_id }}
plugin_name: "snforge-scarb-plugin-compatibility"

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

test-binary:
name: Test binary
needs: [ build-binaries, verify-version, dev-publish-std]
needs: [build-binaries, verify-version, dev-publish-std, dev-publish-plugin, dev-publish-compatibility-plugin]
uses: ./.github/workflows/_test-binaries.yml
secrets: inherit
with:
Expand Down Expand Up @@ -138,10 +158,20 @@ jobs:
secrets: inherit
with:
prod_registry: true
plugin_name: "snforge-scarb-plugin"

publish-snforge-scarb-plugin-compatibility:
name: Publish snforge_scarb_plugin_compatibility
needs: [ test-binary, create-release ]
uses: ./.github/workflows/_publish-plugin.yml
secrets: inherit
with:
prod_registry: true
plugin_name: "snforge-scarb-plugin-compatibility"

publish-to-registry:
name: Publish packages to the registry
needs: [ verify-version, publish-snforge-scarb-plugin ]
needs: [ verify-version, publish-snforge-scarb-plugin, publish-snforge-scarb-plugin-compatibility ]
uses: ./.github/workflows/publish-std.yml
secrets: inherit
with:
Expand Down
11 changes: 11 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ rm crates/snforge-scarb-plugin/Scarb.toml.bak 2> /dev/null
sed -i.bak "/\[package\]/,/version =/ s/version = \".*/version = \"${VERSION}\"/" crates/snforge-scarb-plugin/Cargo.toml
rm crates/snforge-scarb-plugin/Cargo.toml.bak 2> /dev/null

sed -i.bak "/\[package\]/,/version =/ s/version = \".*/version = \"${VERSION}\"/" snforge_std_compatibility/Scarb.toml
rm snforge_std_compatibility/Scarb.toml.bak 2> /dev/null

sed -i.bak "/\[package\]/,/version =/ s/version = \".*/version = \"${VERSION}\"/" crates/snforge-scarb-plugin-deprecated/Scarb.toml
rm crates/snforge-scarb-plugin-deprecated/Scarb.toml.bak 2> /dev/null

sed -i.bak "/\[package\]/,/version =/ s/version = \".*/version = \"${VERSION}\"/" crates/snforge-scarb-plugin-deprecated/Cargo.toml
rm crates/snforge-scarb-plugin-deprecated/Cargo.toml.bak 2> /dev/null

# start: Update cache test data
VERSION_UNDERSCORED=$(echo "$VERSION" | tr '.' '_')

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

scarb --manifest-path snforge_std/Scarb.toml build
scarb --manifest-path snforge_std_compatibility/Scarb.toml build

cargo update
cargo update --manifest-path crates/snforge-scarb-plugin/Cargo.toml
cargo update --manifest-path crates/snforge-scarb-plugin-deprecated/Cargo.toml
Loading