From 9310b9103bae9b99d0cf6eb8f4d4c4f03c2e299f Mon Sep 17 00:00:00 2001 From: pyxis Date: Sat, 9 Dec 2023 01:29:16 +0900 Subject: [PATCH] change to be more general --- .github/workflows/ci.yml | 71 ++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4dd0538..3240c47 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }} @@ -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: @@ -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-*" \ No newline at end of file