Skip to content

Commit

Permalink
GA: publish shotover lib to crates.io (#1106)
Browse files Browse the repository at this point in the history
Co-authored-by: Conor <conor.brosnan@instaclustr.com>
  • Loading branch information
rukai and conorbros authored Apr 11, 2023
1 parent 078c16c commit 2e373f4
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@ on:
- "v*"

jobs:
prepublish-check:
name: "Check that the project is releaseable"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run checks
run: shotover-proxy/build/is_releasable.sh

publish-image:
name: "Publish Docker Image to Docker Hub"
needs: prepublish-check
runs-on: ubuntu-latest
steps:
- name: Login to Docker Hub
Expand All @@ -25,6 +34,7 @@ jobs:
publish-binary:
name: "Publish Binary to GitHub"
needs: prepublish-check
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
Expand All @@ -39,3 +49,18 @@ jobs:
prerelease: false
files: |
*.tar.gz
publish-crates-io:
name: "Publish to crates.io"
needs: prepublish-check
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Install ubuntu packages
run: shotover-proxy/build/install_ubuntu_packages.sh
- name: Publish
run: |
cd shotover
cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }}
43 changes: 43 additions & 0 deletions shotover-proxy/build/is_releasable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash

set -e
set -u

TAG=$(git tag --points-at HEAD)

if [ -z "$TAG" ];
then
echo "Failed: The current commit has no git tags"
exit 1
fi

if [[ $TAG == *$'\n'* ]];
then
echo "Failed: multiple git tags are on the latest commit, but only one tag is allowed"
echo "$TAG"
exit 1
fi

TAG_VERSION=$(echo $TAG | sed -e "s/^v//")

if [ -z "$TAG_VERSION" ];
then
echo "Failed: git tag not valid: '$TAG'"
exit 1
fi

BIN_VERSION="$(cargo metadata --format-version 1 --offline --no-deps | jq -c -M -r '.packages[] | select(.name == "shotover-proxy") | .version')"
if [ "$TAG_VERSION" != "$BIN_VERSION" ];
then
echo "Failed: git tag '$TAG_VERSION' did not match shotover-proxy version '$BIN_VERSION'"
exit 1
fi

LIB_VERSION="$(cargo metadata --format-version 1 --offline --no-deps | jq -c -M -r '.packages[] | select(.name == "shotover") | .version')"
if [ "$TAG_VERSION" != "$LIB_VERSION" ];
then
echo "Failed: git tag '$TAG_VERSION' did not match shotover version '$LIB_VERSION'"
exit 1
fi

echo "Shotover repository is ready for publishing"

0 comments on commit 2e373f4

Please sign in to comment.