Skip to content

Build and release cargo-shuttle #714

Build and release cargo-shuttle

Build and release cargo-shuttle #714

Workflow file for this run

name: Build and release cargo-shuttle
on:
workflow_dispatch: {}
schedule:
- cron: '38 5 * * *'
jobs:
versions:
name: Check whether build is necessary
runs-on: ubuntu-latest
outputs:
upstream_version: ${{ steps.versions.outputs.upstream_version }}
local_version: ${{ steps.versions.outputs.local_version }}
steps:
- id: versions
name: Query Github API for latest versions
run: |
UPSTREAM_VERSION=$(curl -fsSL https://api.github.com/repos/shuttle-hq/shuttle/releases/latest | jq -r '.tag_name')
echo "upstream_version=$UPSTREAM_VERSION" >> $GITHUB_OUTPUT
LOCAL_VERSION=$(curl -fsSL https://api.github.com/repos/jfmontanaro/cargo-shuttle-builds/releases/latest | jq -r '.tag_name')
echo "local_version=$LOCAL_VERSION" >> $GITHUB_OUTPUT
if [[ $LOCAL_VERSION == $UPSTREAM_VERSION ]]; then
echo "Update not needed: $LOCAL_VERSION == $UPSTREAM_VERSION"
else
echo "Update needed: $LOCAL_VERSION => $UPSTREAM_VERSION"
fi
build:
name: Build Shuttle
needs: versions
if: needs.versions.outputs.upstream_version != needs.versions.outputs.local_version
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
include:
- os: ubuntu
filename: cargo-shuttle
- os: windows
filename: cargo-shuttle.exe
- os: macos
filename: cargo-shuttle
steps:
- id: checkout
name: Checkout Shuttle repository
uses: actions/checkout@v3
with:
repository: shuttle-hq/shuttle
- name: Build cargo-shuttle
run: cargo build -p cargo-shuttle --release
- id: upload-artifact
name: Upload binary artifact
uses: actions/upload-artifact@v3
with:
name: cargo-shuttle-${{ matrix.os }}
path: target/release/${{ matrix.filename }}
release:
name: Create Github release
runs-on: ubuntu-latest
needs:
- versions
- build
steps:
- id: download-artifacts
name: Download artifacts
uses: actions/download-artifact@v3
- id: create-release
name: Create Github release and upload assets
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir upload
mv cargo-shuttle-ubuntu/cargo-shuttle upload/cargo-shuttle_x86_64-unknown-linux-gnu
mv cargo-shuttle-windows/cargo-shuttle.exe upload/cargo-shuttle_x86_64-pc-windows-msvc
mv cargo-shuttle-macos/cargo-shuttle upload/cargo-shuttle_x86_64-apple-darwin
cd upload
gh release create ${{ needs.versions.outputs.upstream_version }} --repo jfmontanaro/cargo-shuttle-builds --notes '' *