Skip to content

Commit

Permalink
👷 Add dry run for crates and bolt sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielePicco committed Feb 25, 2024
1 parent 8648710 commit f6cefb1
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 17 deletions.
40 changes: 27 additions & 13 deletions .github/workflows/publish-bolt-crates.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: Publish Bolt crates
on:
release:
types: [published]
types: [ published ]
push:
branches:
- 'release/v*'
workflow_dispatch:

env:
Expand Down Expand Up @@ -106,6 +109,10 @@ jobs:

- uses: actions/checkout@v4

- name: Set DRY_RUN based on trigger
run: echo "DRY_RUN=true" >> $GITHUB_ENV
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/v')

- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -151,7 +158,8 @@ jobs:
- name: Check versions are aligned
run: |
# Fails if versions are not aligned
./scripts/version-align.sh --check
cargo install git-cliff
./version-align.sh --check
- name: run build
run: |
Expand All @@ -173,16 +181,22 @@ jobs:
- name: cargo publish
run: |
cargo publish --manifest-path=crates/bolt-lang/attribute/account/Cargo.toml --token ${CRATES_TOKEN}
cargo publish --manifest-path=crates/bolt-lang/attribute/component/Cargo.toml --token ${CRATES_TOKEN}
cargo publish --manifest-path=crates/bolt-lang/attribute/component-deserialize/Cargo.toml --token ${CRATES_TOKEN}
cargo publish --manifest-path=crates/bolt-lang/attribute/component-id/Cargo.toml --token ${CRATES_TOKEN}
cargo publish --manifest-path=crates/bolt-lang/attribute/system/Cargo.toml --token ${CRATES_TOKEN}
cargo publish --manifest-path=crates/bolt-lang/attribute/system-input/Cargo.toml --token ${CRATES_TOKEN}
cargo publish --manifest-path=crates/bolt-lang/attribute/bolt-program/Cargo.toml --token ${CRATES_TOKEN}
cargo publish --manifest-path=programs/bolt-system/Cargo.toml --token ${CRATES_TOKEN}
cargo publish --manifest-path=programs/bolt-component/Cargo.toml --token ${CRATES_TOKEN}
cargo publish --manifest-path=programs/world/Cargo.toml --token ${CRATES_TOKEN}
cargo publish --manifest-path=crates/bolt-lang/Cargo.toml --token ${CRATES_TOKEN}
DRY_RUN_FLAG=""
if [ "${DRY_RUN}" = "true" ]; then
DRY_RUN_FLAG="--dry-run"
fi
cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-lang/attribute/account/Cargo.toml --token ${CRATES_TOKEN}
cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-lang/attribute/component/Cargo.toml --token ${CRATES_TOKEN}
cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-lang/attribute/component-deserialize/Cargo.toml --token ${CRATES_TOKEN}
cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-lang/attribute/component-id/Cargo.toml --token ${CRATES_TOKEN}
cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-lang/attribute/system/Cargo.toml --token ${CRATES_TOKEN}
cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-lang/attribute/system-input/Cargo.toml --token ${CRATES_TOKEN}
cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-lang/attribute/bolt-program/Cargo.toml --token ${CRATES_TOKEN}
cargo publish $DRY_RUN_FLAG --manifest-path=programs/bolt-system/Cargo.toml --token ${CRATES_TOKEN}
cargo publish $DRY_RUN_FLAG --manifest-path=programs/bolt-component/Cargo.toml --token ${CRATES_TOKEN}
cargo publish $DRY_RUN_FLAG --manifest-path=programs/world/Cargo.toml --token ${CRATES_TOKEN}
cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-lang/Cargo.toml --token ${CRATES_TOKEN}
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
DRY_RUN: ${{ env.DRY_RUN }}
20 changes: 17 additions & 3 deletions .github/workflows/publish-bolt-sdk.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: Publish Bolt SDKs
on:
release:
types: [published]
types: [ published ]
push:
branches:
- 'release/v*'
workflow_dispatch:

env:
Expand Down Expand Up @@ -106,6 +109,10 @@ jobs:

- uses: actions/checkout@v4

- name: Set DRY_RUN based on trigger
run: echo "DRY_RUN=true" >> $GITHUB_ENV
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/v')

- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -151,7 +158,8 @@ jobs:
- name: Check versions are aligned
run: |
# Fails if versions are not aligned
./scripts/version-align.sh --check
cargo install git-cliff
./version-align.sh --check
- name: run build
run: |
Expand All @@ -176,6 +184,12 @@ jobs:
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
cd clients/bolt-sdk/ && yarn build && yarn lint:fix && cd ../../ && yarn lint:fix
cd clients/bolt-sdk/ && npm publish
cd clients/bolt-sdk/
if [ "${DRY_RUN}" = "true" ]; then
echo "Running npm publish in dry-run mode"
npm publish --access public --dry-run
else
npm publish --access public
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 2 additions & 1 deletion .github/workflows/publish-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,15 @@ jobs:
cp "target/${{ matrix.build.TARGET }}/release/${bin}" "${node_pkg}/bin"
# Create the release bin file
release_name="bolt-${{ matrix.build.NAME }}"
release_name="bolt-cli-${{ matrix.build.NAME }}"
if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then
release_name="${release_name}.exe"
fi
echo "release_name=${release_name}" >> $GITHUB_ENV
mv "target/${{ matrix.build.TARGET }}/release/${bin}" "target/${{ matrix.build.TARGET }}/release/${release_name}"
- name: Publish binary to GitHub release
if: env.DRY_RUN != 'true'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down

0 comments on commit f6cefb1

Please sign in to comment.