Create Hermetic Driver Release #39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a release from the latest tag | |
name: Create Release | |
permissions: | |
contents: write | |
on: | |
workflow_dispatch: | |
push: | |
branches: ["main"] | |
paths: | |
- "Cargo.toml" | |
jobs: | |
# Build and packages all the things | |
build-binaries: | |
if: | | |
contains(github.event.head_commit.message, 'chore: Release') == 'true' || | |
contains(github.event.head_commit.message, 'chore: Bump') == 'true' || | |
github.event_name == 'workflow_dispatch' | |
strategy: | |
matrix: | |
# For these target platforms | |
include: | |
- target: x86_64-unknown-linux-gnu | |
os: ubuntu-latest | |
arch: x86_64 | |
ext: deb | |
protoc-arch: linux-x86_64 | |
# - target: x86_64-apple-darwin | |
# os: macos-latest | |
# arch: x86_64 | |
# ext: pkg | |
# protoc-arch: osx-x86_64 | |
- target: aarch64-apple-darwin | |
os: macos-latest | |
config-file: fpm/osx.fpm | |
arch: aarch64 | |
ext: pkg | |
protoc-arch: osx-aarch_64 | |
#- target: x86_64-pc-windows-msvc | |
# os: windows-latest | |
runs-on: ${{ matrix.os }} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install libssl-dev | |
if: matrix.target == 'x86_64-unknown-linux-gnu' | |
run: sudo apt-get install libssl-dev pkg-config | |
- name: Brew install openssl | |
if: matrix.target == 'aarch64-apple-darwin' | |
run: brew install openssl | |
- name: Install Rust | |
run: | | |
rustup update stable | |
rustup default stable | |
- name: Setup target | |
run: rustup target add ${{ matrix.target }} | |
- name: Run package script | |
run: | | |
cargo build --release --locked --target ${{ matrix.target }} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: hermetic-driver-${{ matrix.target }} | |
path: target/${{ matrix.target }}/release/hermetic-driver | |
create-release: | |
name: Create Release | |
runs-on: ubuntu-latest | |
needs: [build-binaries] | |
outputs: | |
build_tag: ${{ steps.release.outputs.tag }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
- name: check artifacts | |
run: | | |
ls artifacts/**/* | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- id: release | |
run: | | |
export TAG=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[0].version' ) | |
echo "Releasing "$TAG | |
echo "tag=${TAG}" >> "$GITHUB_OUTPUT" | |
mkdir -p artifacts/output | |
cp artifacts/hermetic-driver-x86_64-unknown-linux-gnu/hermetic-driver \ | |
artifacts/output/hermetic-driver-x86_64-linux | |
cp artifacts/hermetic-driver-aarch64-apple-darwin/hermetic-driver \ | |
artifacts/output/hermetic-driver-aarch64-apple-darwin | |
current_branch=$(git rev-parse --abbrev-ref HEAD) | |
gh release create "v${TAG}" \ | |
--generate-notes \ | |
--target "$current_branch" \ | |
--generate-notes \ | |
--latest \ | |
artifacts/output/hermetic-driver-x86_64-linux \ | |
artifacts/output/hermetic-driver-aarch64-apple-darwin | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Public ECR | |
uses: docker/login-action@v2 | |
with: | |
registry: public.ecr.aws | |
username: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
env: | |
AWS_REGION: us-east-1 | |
- name: Build and Publish | |
run: make BUILD_TAG=${{ needs.release.outputs.tag }} publish-hermetic-driver |