Skip to content

Commit

Permalink
Add upload to registry workflow for foundry_std (#2461)
Browse files Browse the repository at this point in the history
<!-- Reference any GitHub issues resolved by this PR -->

Closes #2344
Closes #2463 

This PR is a part of the stack:
-- Add missing info recommended for package uploads
(#2460)
--> Add github action workflow for automatic registry uploads during
release (This PR)

## Introduced changes

<!-- A brief description of the changes -->

- Updates github workflow to also upload std libraries to scarbs
registry during release
- Sets snforge_scarb_plugin to specific version downloadable from the
registry, as required by scarb

## Checklist

<!-- Make sure all of these are complete -->

- [X] Linked relevant issue
- [X] Updated relevant documentation
- [X] Added relevant tests
- [X] Performed self-review of the code
- [X] Added changes to `CHANGELOG.md`

---------

Co-authored-by: kkawula <[email protected]>
  • Loading branch information
THenry14 and kkawula authored Nov 22, 2024
1 parent 2027d71 commit a6b9785
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/publish_plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish snforge_scarb_plugin

on:
workflow_call:
workflow_dispatch:

jobs:
upload-to-registry:
name: Upload plugin to the registry
runs-on: ubuntu-latest
env:
SCARB_REGISTRY_AUTH_TOKEN: ${{ secrets.SCARB_REGISTRY_AUTH_TOKEN }}
steps:
- uses: actions/checkout@v4

- name: Check version
id: check-version
if: ${{ github.event_name != 'workflow_dispatch' }}
run: |
set -exo pipefail
snforge_scarb_plugin_version=$(grep version crates/snforge-scarb-plugin/Scarb.toml | cut -d '"' -f 2)
snforge_scarb_plugin_uploaded=$(curl -s https://scarbs.xyz/api/v1/index/sn/fo/snforge_scarb_plugin.json | jq --arg version "$snforge_scarb_plugin_version" '[.[] | select(.v == $version)] | length > 0')
echo "snforge_scarb_plugin_uploaded=$snforge_scarb_plugin_uploaded" >> $GITHUB_OUTPUT
- uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a
with:
toolchain: stable

- uses: software-mansion/setup-scarb@v1
with:
scarb-version: "2.8.5"

- name: Publish snforge_scarb_plugin
if: ${{ steps.check-version.outputs.snforge_scarb_plugin_uploaded == 'false' || github.event_name == 'workflow_dispatch' }}
working-directory: crates/snforge-scarb-plugin
run: scarb publish
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,35 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.create-release.outputs.computed-prefix }}${{ steps.create-release.outputs.version }}

publish-snforge-scarb-plugin:
name: Publish snforge_scarb_plugin
uses: ./.github/workflows/publish_plugin.yml
secrets: inherit

publish-to-registry:
name: Publish packages to the registry
runs-on: ubuntu-latest
needs: [ create-release, publish-snforge-scarb-plugin ]
env:
SCARB_REGISTRY_AUTH_TOKEN: ${{ secrets.SCARB_REGISTRY_AUTH_TOKEN }}
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a
with:
toolchain: stable

- uses: software-mansion/setup-scarb@v1
with:
scarb-version: "2.8.5"

- name: Publish sncast_std
working-directory: sncast_std
run: scarb publish --allow-dirty

- name: Publish snforge_std
working-directory: snforge_std
run: |
../scripts/set_plugin_version.sh
scarb publish --allow-dirty
10 changes: 10 additions & 0 deletions scripts/set_plugin_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

PLUGIN_FILE_PATH="../crates/snforge-scarb-plugin/Scarb.toml"
SNFORGE_STD_PATH="../snforge_std/Scarb.toml"

VERSION=$(grep version "$PLUGIN_FILE_PATH" | cut -d '"' -f 2)

sed -i.bak "/snforge_scarb_plugin/ s/\(snforge_scarb_plugin = \).*/\1\"^${VERSION}\"/" $SNFORGE_STD_PATH

rm ${SNFORGE_STD_PATH}.bak 2> /dev/null

0 comments on commit a6b9785

Please sign in to comment.