Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add and use setup-libmagic GitHub Action #41

Merged
merged 1 commit into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/actions/setup-libmagic/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: setup-libmagic
description: Setup some version of `libmagic` for `magic-sys`

runs:
using: 'composite'
steps:
# setup cache
- name: setup cache
if: ${{ runner.os == 'Windows' }}
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');


# update packages

- name: update packages
if: ${{ runner.os == 'Linux' }}
run: sudo apt-get update
shell: bash

- name: update packages
if: ${{ runner.os == 'Windows' }}
run: vcpkg update
shell: bash

- name: update packages
if: ${{ runner.os == 'macOS' }}
run: brew update
shell: bash


# install packages

- name: install packages
if: ${{ runner.os == 'Linux' }}
run: sudo apt-get install libmagic1 libmagic-dev pkg-config
shell: bash

- name: install packages
if: ${{ runner.os == 'Windows' }}
run: |
vcpkg install libmagic:x64-windows-static-md
echo "VCPKG_ROOT=${VCPKG_INSTALLATION_ROOT}" >> "${GITHUB_ENV}"
shell: bash

- name: install packages
if: ${{ runner.os == 'macOS' }}
run: brew install libmagic pkg-config
shell: bash


# setup environment

- name: setup environment
if: ${{ runner.os == 'Linux' }}
run: echo "VCPKGRS_NO_LIBMAGIC=1" >> "${GITHUB_ENV}"
shell: bash

- name: setup environment
if: ${{ runner.os == 'Windows' }}
run: echo "LIBMAGIC_NO_PKG_CONFIG=1" >> "${GITHUB_ENV}"
shell: bash

- name: setup environment
if: ${{ runner.os == 'macOS' }}
run: echo "VCPKGRS_NO_LIBMAGIC=1" >> "${GITHUB_ENV}"
shell: bash

# setup static build

- name: setup static build
if: ${{ runner.os == 'Linux' }}
run: echo "LIBMAGIC_STATIC=1" >> "${GITHUB_ENV}"
shell: bash

- name: setup static build
if: ${{ runner.os == 'Windows' }}
run: echo "Static builds are the default for vcpkg-rs"
shell: bash

- name: setup static build
if: ${{ runner.os == 'macOS' }}
run: echo "LIBMAGIC_STATIC=1" >> "${GITHUB_ENV}"
shell: bash
1 change: 1 addition & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:

steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup-libmagic
- name: Build
run: cargo build --verbose
- name: Run tests
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: brew
run: |
brew update
brew install libmagic
- uses: ./.github/actions/setup-libmagic
- name: install Rust MSRV
uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f # v1.0.6
with:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: vcpkg
run: |
cargo +stable install cargo-vcpkg
cargo vcpkg build
- uses: ./.github/actions/setup-libmagic
- name: Build
run: cargo build --verbose
- name: Run tests
Expand Down
Loading