Skip to content

Commit

Permalink
change to be more general
Browse files Browse the repository at this point in the history
  • Loading branch information
pyxis committed Dec 8, 2023
1 parent a223eb4 commit 9310b91
Showing 1 changed file with 46 additions and 25 deletions.
71 changes: 46 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ on:
permissions:
contents: write

env:
CRATE_NAME: adb-devices-prometheus-exporter
GITHUB_TOKEN: ${{ github.token }}
RUST_BACKTRACE: 1

jobs:
build:
name: ${{ matrix.platform.os_name }} with rust ${{ matrix.toolchain }}
Expand All @@ -16,35 +21,51 @@ jobs:
fail-fast: false
matrix:
platform:
- os_name: Linux-x86_64
os: ubuntu-20.04
target: x86_64-unknown-linux-musl
bin: adb-devices-prometheus-exporter
name: adb-devices-prometheus-exporter-Linux-x86_64-musl.tar.gz
- os_name: Linux-aarch64
os: ubuntu-20.04
target: aarch64-unknown-linux-musl
bin: adb-devices-prometheus-exporter-linux-arm64
archive: adb-devices-prometheus-exporter-linux-arm64.tar.gz
- os_name: Linux-x86_64
os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
bin: adb-devices-prometheus-exporter-linux-amd64
archive: adb-devices-prometheus-exporter-linux-amd64.tar.gz
bin: adb-devices-prometheus-exporter
name: adb-devices-prometheus-exporter-Linux-aarch64-musl.tar.gz
- os_name: Windows-aarch64
os: windows-latest
target: aarch64-pc-windows-msvc
bin: adb-devices-prometheus-exporter.exe
name: adb-devices-prometheus-exporter-Windows-aarch64.zip
- os_name: Windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
bin: adb-devices-prometheus-exporter-amd64.exe
archive: adb-devices-prometheus-exporter-amd64.zip
bin: adb-devices-prometheus-exporter.exe
name: adb-devices-prometheus-exporter-Windows-x86_64.zip
- os_name: macOS-x86_64
os: macOS-latest
target: x86_64-apple-darwin
bin: adb-devices-prometheus-exporter-darwin-amd64
archive: adb-devices-prometheus-exporter-darwin-amd64.tar.gz
bin: adb-devices-prometheus-exporter
name: adb-devices-prometheus-exporter-Darwin-x86_64.tar.gz
- os_name: macOS-aarch64
os: macOS-latest
target: aarch64-apple-darwin
bin: adb-devices-prometheus-exporter-darwin-arm64
archive: adb-devices-prometheus-exporter-darwin-arm64.tar.gz
bin: adb-devices-prometheus-exporter
name: adb-devices-prometheus-exporter-Darwin-aarch64.tar.gz
toolchain:
- stable
- beta
- nightly
steps:
- uses: actions/checkout@v3
- name: Cache cargo & target directories
uses: Swatinem/rust-cache@v2
- name: Configure Git
run: |
git config --global user.email "pyxis@uzuki.live"
git config --global user.name "Pyxis"
- name: Install musl-tools on Linux
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
if: contains(matrix.platform.name, 'musl')
- name: Build binary
uses: houseabsolute/actions-rust-cross@v0
with:
Expand All @@ -53,27 +74,27 @@ jobs:
toolchain: ${{ matrix.toolchain }}
args: "--locked --release"
strip: true
- name: Rename binary (linux and macos)
run: mv target/${{ matrix.platform.target }}/release/adb-devices-prometheus-exporter target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}
if: matrix.platform.os_name != 'Windows-x86_64'
- name: Rename binary (windows)
run: mv target/${{ matrix.platform.target }}/release/adb-devices-prometheus-exporter.exe target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}
if: matrix.platform.os_name == 'Windows-x86_64'
- name: Package as archive
shell: bash
run: |
cd target/${{ matrix.platform.target }}/release
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then
7z a ../../../${{ matrix.platform.archive }} ${{ matrix.platform.bin }}
7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
else
tar czvf ../../../${{ matrix.platform.archive }} ${{ matrix.platform.bin }}
tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
fi
cd -
if: matrix.toolchain == 'stable'
- name: Publish release artifacts
uses: actions/upload-artifact@v3
with:
name: adb-devices-prometheus-exporter-${{ matrix.platform.os_name }}
path: "adb-devices-prometheus-exporter-*"
if: matrix.toolchain == 'stable'
- name: Generate SHA-256
run: shasum -a 256 target/${{ matrix.platform.target }}/release/${{ matrix.platform.archive }} | cut -d ' ' -f 1 > target/${{ matrix.platform.target }}/release/${{ matrix.platform.archive }}.sha256
run: shasum -a 256 ${{ matrix.platform.name }}
if: matrix.toolchain == 'stable' && matrix.platform.os == 'macOS-latest'
- name: Release binary and SHA-256 checksum to GitHub
uses: softprops/action-gh-release@v1
with:
files: |
target/${{ matrix.platform.target }}/release/${{ matrix.platform.archive }}
target/${{ matrix.platform.target }}/release/${{ matrix.platform.archive }}.sha256
files: "adb-devices-prometheus-exporter-*"

0 comments on commit 9310b91

Please sign in to comment.