Skip to content

Commit

Permalink
ci: fix publishing bugs to crates.io
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielsimard committed Jun 14, 2022
1 parent b44d9a1 commit 0ab630c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
28 changes: 24 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
- '*'

jobs:
publish:
name: publish
publish-mock-it_codegen:
name: publish-mock-it_codegen
runs-on: ubuntu-latest
steps:
- name: checkout
Expand All @@ -20,7 +20,27 @@ jobs:
toolchain: stable
override: true

- name: publish to crates.io
run: ./ci/publish.sh
- name: publish mock-it_codegen to crates.io
run: ./ci/publish.sh mock-it_codegen
env:
CRATES_IO_API_TOKEN: ${{ secrets.CRATES_IO_API_TOKEN }}

publish-mock-it:
needs: publish-mock-it_codegen
name: publish-mock-it
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2

- name: install rust stable
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: publish mock-it to crates.io
run: ./ci/publish.sh mock-it
env:
CRATES_IO_API_TOKEN: ${{ secrets.CRATES_IO_API_TOKEN }}
26 changes: 16 additions & 10 deletions ci/publish.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
#!/bin/bash

echo "Publishing mock-it_codegen ..."
cd mock-it_codegen/
cargo publish --token ${CRATES_IO_API_TOKEN}
echo "Sucessfully published mock-it_codegen"
crate=$1

echo "Waiting 10 seconds for mock-it_codegen to be available ..."
sleep 10
case ${crate} in
mock-it_codegen)
cd mock-it_codegen/
echo "Publishing mock-it_codegen ..."
;;
mock-it)
echo "Publishing mock-it ..."
;;
*)
echo "Crate ${crate} unknown"
exit 1
;;
esac

echo "Publishing mock-it ..."
cd ../
cargo publish --token ${CRATES_IO_API_TOKEN}
echo "Sucessfully published mock-it"
cargo publish --token ${CRATES_IO_API_TOKEN} || exit 1
echo "Sucessfully published ${crate}"

0 comments on commit 0ab630c

Please sign in to comment.