From 0ab630ca12531c65a82a7f3e1c5c7714a8b65ea1 Mon Sep 17 00:00:00 2001 From: nathaniel Date: Tue, 14 Jun 2022 18:06:51 -0400 Subject: [PATCH] ci: fix publishing bugs to crates.io --- .github/workflows/publish.yml | 28 ++++++++++++++++++++++++---- ci/publish.sh | 26 ++++++++++++++++---------- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4096eb7..967ddd9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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 @@ -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 }} diff --git a/ci/publish.sh b/ci/publish.sh index 915c0f0..0b5ae2d 100755 --- a/ci/publish.sh +++ b/ci/publish.sh @@ -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}"