-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build the program on Windows and macOS
- Loading branch information
1 parent
cc35803
commit 34dfd3a
Showing
1 changed file
with
117 additions
and
41 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ on: | |
- '**.md' | ||
- 'assets/*' | ||
jobs: | ||
build: | ||
build-linux: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
strategy: | ||
|
@@ -36,6 +36,7 @@ jobs: | |
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
default: true | ||
target: ${{ matrix.target }} | ||
override: true | ||
- name: Build | ||
|
@@ -45,21 +46,18 @@ jobs: | |
run: echo "::set-output name=name::$(cargo metadata --format-version 1 | jq -r '.workspace_members[0]' | cut -d' ' -f 1)" | ||
- name: Prepare the artifact folder | ||
run: mkdir artifact | ||
- name: Prepare the artifact | ||
run: cp "target/${TARGET}/release/${PACKAGE_NAME}" artifact/ | ||
if: ${{ !contains(matrix.target, 'windows') }} | ||
- name: Strip the built binary | ||
run: strip -s "target/${TARGET}/release/${PACKAGE_NAME}" | ||
env: | ||
TARGET: ${{ matrix.target }} | ||
PACKAGE_NAME: ${{ steps.package.outputs.name }} | ||
- name: Prepare the artifact (Windows) | ||
run: cp "target/${TARGET}/release/${PACKAGE_NAME}.exe" artifact/ | ||
if: ${{ contains(matrix.target, 'windows') }} | ||
- name: Prepare the artifact | ||
run: cp "target/${TARGET}/release/${PACKAGE_NAME}" artifact/ | ||
env: | ||
TARGET: ${{ matrix.target }} | ||
PACKAGE_NAME: ${{ steps.package.outputs.name }} | ||
- name: Prepare the udev rules | ||
run: cp assets/*.rules artifact/ | ||
if: ${{ contains(matrix.target, 'linux') }} | ||
- name: Get the short commit SHA | ||
id: slug | ||
run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)" | ||
|
@@ -68,6 +66,92 @@ jobs: | |
with: | ||
name: ${{ steps.package.outputs.name }}-${{ matrix.target }}-${{ steps.slug.outputs.sha7 }} | ||
path: artifact | ||
build-macos: | ||
name: Build | ||
runs-on: macos-latest | ||
strategy: | ||
matrix: | ||
target: | ||
- x86_64-apple-darwin | ||
# It doesn't seem to be possible to build a aarch64 binary on an x64 host | ||
# https://github.com/actions/virtual-environments/issues/2187 | ||
# - aarch64-apple-darwin | ||
steps: | ||
- name: Checkout the code | ||
uses: actions/checkout@v2 | ||
with: | ||
persist-credentials: false | ||
- name: Install the Rust toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
default: true | ||
target: ${{ matrix.target }} | ||
override: true | ||
- name: Build | ||
run: cargo build --release --target=${{ matrix.target }} | ||
- name: Get the package name | ||
id: package | ||
run: echo "::set-output name=name::$(cargo metadata --format-version 1 | jq -r '.workspace_members[0]' | cut -d' ' -f 1)" | ||
- name: Prepare the artifact folder | ||
run: mkdir artifact | ||
- name: Strip the built binary | ||
run: strip -S -x "target/${TARGET}/release/${PACKAGE_NAME}" | ||
env: | ||
TARGET: ${{ matrix.target }} | ||
PACKAGE_NAME: ${{ steps.package.outputs.name }} | ||
- name: Prepare the artifact | ||
run: cp "target/${TARGET}/release/${PACKAGE_NAME}" artifact/ | ||
env: | ||
TARGET: ${{ matrix.target }} | ||
PACKAGE_NAME: ${{ steps.package.outputs.name }} | ||
- name: Get the short commit SHA | ||
id: slug | ||
run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)" | ||
- name: Upload the artifact | ||
uses: actions/[email protected] | ||
with: | ||
name: ${{ steps.package.outputs.name }}-${{ matrix.target }}-${{ steps.slug.outputs.sha7 }} | ||
path: artifact | ||
build-windows: | ||
name: Build | ||
runs-on: windows-latest | ||
strategy: | ||
matrix: | ||
target: | ||
- x86_64-pc-windows-msvc | ||
steps: | ||
- name: Checkout the code | ||
uses: actions/checkout@v2 | ||
with: | ||
persist-credentials: false | ||
- name: Install the Rust toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
default: true | ||
target: ${{ matrix.target }} | ||
override: true | ||
- name: Build | ||
run: cargo build --release --target=${{ matrix.target }} | ||
- name: Get the package name | ||
id: package | ||
run: echo "::set-output name=name::$(cargo metadata --format-version 1 | jq -r '.workspace_members[0]' | %{ $_.split(" ")[0] })" | ||
- name: Prepare the artifact folder | ||
run: mkdir artifact | ||
- name: Prepare the artifact | ||
run: cp "target\${env:TARGET}\release\${env:PACKAGE_NAME}.exe" artifact\ | ||
env: | ||
TARGET: ${{ matrix.target }} | ||
PACKAGE_NAME: ${{ steps.package.outputs.name }} | ||
- name: Get the short commit SHA | ||
id: slug | ||
run: echo "::set-output name=sha7::$(echo ${env:GITHUB_SHA} | %{ $_.substring(0, 7) })" | ||
- name: Upload the artifact | ||
uses: actions/[email protected] | ||
with: | ||
name: ${{ steps.package.outputs.name }}-${{ matrix.target }}-${{ steps.slug.outputs.sha7 }} | ||
path: artifact | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
|
@@ -89,7 +173,9 @@ jobs: | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | ||
name: Release | ||
needs: | ||
- build | ||
- build-linux | ||
- build-macos | ||
- build-windows | ||
- lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
@@ -110,45 +196,35 @@ jobs: | |
- name: Download the build artifact (Linux x64) | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: ${{ steps.package.outputs.name }}-x86_64-unknown-linux-musl-${{ steps.slug.outputs.sha7 }} | ||
name: ${{ steps.package.outputs.name }}-x86_64-unknown-linux-gnu-${{ steps.slug.outputs.sha7 }} | ||
path: release-linux-x64 | ||
- name: Archive the build artifact (Linux x64) | ||
run: tar -cvzf "${PACKAGE_NAME}-${TARGET}-${VERSION}.tar.gz" "release-${TARGET}"/* | ||
env: | ||
PACKAGE_NAME: ${{ steps.package.outputs.name }} | ||
VERSION: ${{ steps.tagName.outputs.version }} | ||
TARGET: linux-x64 | ||
# - name: Download the build artifact (macOS x64) | ||
# uses: actions/download-artifact@v2 | ||
# with: | ||
# name: ${{ steps.package.outputs.name }}-x86_64-apple-darwin-${{ steps.slug.outputs.sha7 }} | ||
# path: release-macos-x64 | ||
# - name: Archive the build artifact (macOS x64) | ||
# run: cd "release-${TARGET}" && zip -9 -r "../${PACKAGE_NAME}-${TARGET}-${VERSION}.zip" * | ||
# env: | ||
# PACKAGE_NAME: ${{ steps.package.outputs.name }} | ||
# VERSION: ${{ steps.tagName.outputs.version }} | ||
# TARGET: macos-x64 | ||
# - name: Download the build artifact (macOS ARM64) | ||
# uses: actions/download-artifact@v2 | ||
# with: | ||
# name: ${{ steps.package.outputs.name }}-aarch64-apple-darwin-${{ steps.slug.outputs.sha7 }} | ||
# path: release-macos-arm64 | ||
# - name: Archive the build artifact (macOS ARM64) | ||
# run: cd "release-${TARGET}" && zip -9 -r "../${PACKAGE_NAME}-${TARGET}-${VERSION}.zip" * | ||
# env: | ||
# VERSION: ${{ steps.tagName.outputs.version }} | ||
# TARGET: macos-arm64 | ||
# - name: Download the build artifact (Windows x64) | ||
# uses: actions/download-artifact@v2 | ||
# with: | ||
# name: ${{ steps.package.outputs.name }}-x86_64-pc-windows-msvc-${{ steps.slug.outputs.sha7 }} | ||
# path: release-windows-x64 | ||
# - name: Archive the build artifact (Windows x64) | ||
# run: cd "release-${TARGET}" && zip -9 -r "../${PACKAGE_NAME}-${TARGET}-${VERSION}.zip" * | ||
# env: | ||
# VERSION: ${{ steps.tagName.outputs.version }} | ||
# TARGET: windows-x64 | ||
- name: Download the build artifact (macOS x64) | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: ${{ steps.package.outputs.name }}-x86_64-apple-darwin-${{ steps.slug.outputs.sha7 }} | ||
path: release-macos-x64 | ||
- name: Archive the build artifact (macOS x64) | ||
run: cd "release-${TARGET}" && zip -9 -r "../${PACKAGE_NAME}-${TARGET}-${VERSION}.zip" * | ||
env: | ||
PACKAGE_NAME: ${{ steps.package.outputs.name }} | ||
VERSION: ${{ steps.tagName.outputs.version }} | ||
TARGET: macos-x64 | ||
- name: Download the build artifact (Windows x64) | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: ${{ steps.package.outputs.name }}-x86_64-pc-windows-msvc-${{ steps.slug.outputs.sha7 }} | ||
path: release-windows-x64 | ||
- name: Archive the build artifact (Windows x64) | ||
run: cd "release-${TARGET}" && zip -9 -r "../${PACKAGE_NAME}-${TARGET}-${VERSION}.zip" * | ||
env: | ||
VERSION: ${{ steps.tagName.outputs.version }} | ||
TARGET: windows-x64 | ||
- name: Create a new release | ||
uses: ncipollo/release-action@v1 | ||
env: | ||
|