taiki-e / upload-rust-binary-action

GitHub Action for building and uploading Rust binary to GitHub Releases.
Apache License 2.0
227 stars 19 forks source link

Dependency install for specific matrix.os #53

Closed jacknicklenson closed 10 months ago

jacknicklenson commented 10 months ago

Hi, I want to install some dependencies before compile, but I cannot make it work. Here is my yml file:

name: Release

permissions:
  contents: write

on:
  push:
    tags:
      - v[0-9]+.*

env:
  CARGO_TERM_COLOR: always

jobs:
  create-release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: taiki-e/create-gh-release-action@v1
        with:
          # (required) GitHub token for creating GitHub Releases.
          token: ${{ secrets.GITHUB_TOKEN }}

  upload-assets:
    strategy:
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
          - target: aarch64-apple-darwin
            os: macos-latest
          - target: x86_64-apple-darwin
            os: macos-latest
          - target: x86_64-pc-windows-msvc
            os: windows-latest
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v3
        if: startsWith(matrix.os, 'ubuntu')
      - name: Set the version
        shell: bash
        run: sudo apt-get install -y pkg-config libx11-dev libxi-dev libgl1-mesa-dev libasound2-dev
      - uses: taiki-e/upload-rust-binary-action@v1
        with:
          # (required)
          bin: rustyed
          include: rustyed.conf,fonts
          asset: rustyed.conf
          target: ${{ matrix.target }}
          # (optional) On which platform to distribute the `.tar.gz` file.
          # [default value: unix]
          # [possible values: all, unix, windows, none]
          tar: unix
          # (optional) On which platform to distribute the `.zip` file.
          # [default value: windows]
          # [possible values: all, unix, windows, none]
          zip: windows
        env:
          # (required)
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

When action runs it runs shell command on all OSes and thus it's fail.

How can I install dependencies for specific os before compile & release action happen.

taiki-e commented 10 months ago
       - uses: actions/checkout@v3
-        if: startsWith(matrix.os, 'ubuntu')
       - name: Set the version
         shell: bash
         run: sudo apt-get install -y pkg-config libx11-dev libxi-dev libgl1-mesa-dev libasound2-dev
+        if: startsWith(matrix.os, 'ubuntu')

You have to add if: startsWith(matrix.os, 'ubuntu') to a run: that calls apt-get.