Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GA: publish shotover lib to crates.io #1106

Merged
merged 5 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"