Skip to content

Commit

Permalink
Add release job to workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
arcaartem committed Feb 5, 2023
1 parent ffa6ecf commit abcab57
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 5 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Release
on:
push:
tags:
- '*'

jobs:
build-for-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Add targets
run: |
rustup target add aarch64-apple-darwin
rustup target add x86_64-apple-darwin
- name: Build
run: cargo build --release --target x86_64-apple-darwin --target aarch64-apple-darwin
- name: Run tests
run: cargo test
- name: Set env
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo "BIN_NAME=$(cat Cargo.toml | grep name | sed -E 's/.*"(.*)".*/\1/')" >> $GITHUB_ENV
- name: Zip artifacts
run: |
mkdir -p artifacts/
pushd artifacts
echo zip ${BIN_NAME}-${RELEASE_VERSION}-x86_64-apple-darwin.zip ../target/x86_64-apple-darwin/release/${BIN_NAME}
zip -j ${BIN_NAME}-${RELEASE_VERSION}-x86_64-apple-darwin.zip ../target/x86_64-apple-darwin/release/${BIN_NAME}
echo zip ${BIN_NAME}-${RELEASE_VERSION}-aarch64-apple-darwin.zip ../target/aarch64-apple-darwin/release/${BIN_NAME}
zip -j ${BIN_NAME}-${RELEASE_VERSION}-aarch64-apple-darwin.zip ../target/aarch64-apple-darwin/release/${BIN_NAME}
popd
- uses: actions/upload-artifact@v2
with:
name: macos-binaries
path: artifacts/*.zip
build-for-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Add targets
run: rustup target add x86_64-unknown-linux-musl
- name: Build
run: cargo build --release --target x86_64-unknown-linux-musl
- name: Run tests
run: cargo test
- name: Set env
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo "BIN_NAME=$(cat Cargo.toml | grep name | sed -E 's/.*"(.*)".*/\1/')" >> $GITHUB_ENV
- name: Zip artifacts
run: |
mkdir -p artifacts/
pushd artifacts
echo zip ${BIN_NAME}-${RELEASE_VERSION}-x86_64-unknown-linux-musl.zip ../target/x86_64-unknown-linux-musl/release/${BIN_NAME}
zip -j ${BIN_NAME}-${RELEASE_VERSION}-x86_64-unknown-linux-musl.zip ../target/x86_64-unknown-linux-musl/release/${BIN_NAME}
popd
- uses: actions/upload-artifact@v2
with:
name: linux-binaries
path: artifacts/*.zip
release:
needs: [build-for-macos, build-for-linux]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v2
with:
path: artifacts/
- uses: ncipollo/release-action@v1
with:
artifacts: "artifacts/**/*.zip"

21 changes: 16 additions & 5 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,24 @@ env:
CARGO_TERM_COLOR: always

jobs:
build:

build-for-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Add targets
run: |
rustup target add aarch64-apple-darwin
rustup target add x86_64-apple-darwin
- name: Build
run: cargo build --target x86_64-apple-darwin --target aarch64-apple-darwin
- name: Run tests
run: cargo test
build-for-linux:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build --verbose
run: cargo build
- name: Run tests
run: cargo test --verbose
run: cargo test

0 comments on commit abcab57

Please sign in to comment.