Skip to content

Commit

Permalink
Merge pull request #140 from instaclustr/add_release_infra
Browse files Browse the repository at this point in the history
Add release infra
  • Loading branch information
rukai authored Dec 4, 2024
2 parents a53af3f + e721c8f commit 0050622
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: "tagged-release"

on:
push:
tags:
- "v*"

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

publish-binary:
name: "Publish Binary to GitHub"
needs: prepublish-check
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Build & test
run: atsc/release/build_release.sh
- name: Publish
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
files: |
*.tar.gz
19 changes: 19 additions & 0 deletions atsc/release/build_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

set -e

SCRIPT_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

cd $SCRIPT_DIR

cargo build --release

mkdir -p atsc
cp ../../target/release/atsc atsc

# extract the crate version from Cargo.toml
CRATE_VERSION="$(cargo metadata --format-version 1 --offline --no-deps | jq -c -M -r '.packages[] | select(.name == "atsc") | .version')"
tar -cvzf out.tar.gz atsc
mv out.tar.gz atsc-linux_amd64-${CRATE_VERSION}.tar.gz

rm -rf atsc
37 changes: 37 additions & 0 deletions atsc/release/is_releasable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/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 == "atsc") | .version')"
if [ "$TAG_VERSION" != "$BIN_VERSION" ];
then
echo "Failed: git tag '$TAG_VERSION' did not match atsc version '$BIN_VERSION'"
exit 1
fi


echo "ATSC repository is ready for publishing"

0 comments on commit 0050622

Please sign in to comment.