Skip to content

Commit

Permalink
ci: Add GitHub Action (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
suxb201 authored Jul 22, 2024
1 parent 46a4b17 commit b2b2bc4
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://github.com/release-drafter/release-drafter#example
name-template: 'resp-benchmark-v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
template: |
## Changes
$CHANGES
122 changes: 122 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: release

# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
draft:
name: draft
runs-on: ubuntu-latest
steps:
- name: draft release
id: "draft"
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
upload_url: ${{ steps.draft.outputs.upload_url }}

build-and-upload:
needs: draft
name: build - ${{ matrix.platform.release_for }}
strategy:
matrix:
platform:
- release_for: linux-amd64
os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
bin: resp-benchmark
name: resp-benchmark-linux-amd64.tar.gz
command: build

- release_for: linux-arm64
os: ubuntu-20.04
target: aarch64-unknown-linux-gnu
bin: resp-benchmark
name: resp-benchmark-linux-arm64.tar.gz
command: build

- release_for: windows-amd64
os: windows-latest
target: x86_64-pc-windows-msvc
bin: resp-benchmark.exe
name: resp-benchmark-windows-amd64.zip
command: build

- release_for: windows-arm64
os: windows-latest
target: aarch64-pc-windows-msvc
bin: resp-benchmark.exe
name: resp-benchmark-windows-arm64.zip
command: build

- release_for: macos-amd64
os: macos-latest
target: x86_64-apple-darwin
bin: resp-benchmark
name: resp-benchmark-macos-amd64.tar.gz
command: build

- release_for: macos-arm64
os: macos-latest
target: aarch64-apple-darwin
bin: resp-benchmark
name: resp-benchmark-macos-arm64.tar.gz
command: build

runs-on: ${{ matrix.platform.os }}
steps:
- name: checkout
uses: actions/checkout@v3

- name: cache cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: cache cargo index
uses: actions/cache@v3
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-index-
- name: cache cargo build
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: build binary
uses: houseabsolute/actions-rust-cross@v0
with:
command: ${{ matrix.platform.command }}
target: ${{ matrix.platform.target }}
args: "--locked --release"
strip: true
- name: Package as archive
shell: bash
run: |
cd target/${{ matrix.platform.target }}/release
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then
7z a ${{ matrix.platform.name }} ${{ matrix.platform.bin }} ../../../workloads
else
tar czvf ${{ matrix.platform.name }} ${{ matrix.platform.bin }} ../../../workloads
fi
- name: upload
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ needs.draft.outputs.upload_url }}
asset_path: ./target/${{ matrix.platform.target }}/release/${{ matrix.platform.name }}
asset_name: ${{ matrix.platform.name }}
asset_content_type: ${{ matrix.platform.os == 'windows-latest' && 'application/zip' || 'application/gzip' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
.idea/

0 comments on commit b2b2bc4

Please sign in to comment.