Skip to content

Commit

Permalink
Add better macos builds.
Browse files Browse the repository at this point in the history
Add macos target.

Fix reusable_linux.yml

Another fix for reusable_linux.yml

Exclude macos-latest from more jobs.

Separate macos files into a new yaml file.

Don't double tap 'brew install pcre2'
  • Loading branch information
spamwax committed Jul 15, 2022
1 parent 4c791d5 commit 38bcc6b
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 5 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,12 @@ jobs:
arm: true
build_type: 'debug'
run_tests: true
macos:
if: ${{ github.ref_type != 'tag' }}
uses: ./.github/workflows/reusable_macos.yml
with:
target: 'x86_64-apple-darwin'
build_type: 'debug'
run_tests: true


4 changes: 2 additions & 2 deletions .github/workflows/prepare_artifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ set -ex

create_linux() {
pwd
ls -la
artifacts=rmate_"$TARGET".tar.gz
strip_cmd="strip"

Expand All @@ -15,15 +14,16 @@ create_linux() {
cp target/"$TARGET/$BUILD_TYPE"/rmate . || true
"$strip_cmd" rmate || true
tar czvf "$artifacts" rmate
ls -la
}

create_macos() {
pwd
ls -la
artifacts=rmate_"$TARGET".zip
cp target/"$TARGET/$BUILD_TYPE"/rmate . || true
strip rmate || true
zip "$artifacts" rmate
ls -la
}

if [ -z "$RELEASE_COMMIT" ]; then
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,13 @@ jobs:
arm: true
build_type: 'release'
run_tests: false
macos:
if: ${{ github.ref_type == 'tag' && github.ref_name != 'master' }}
uses: ./.github/workflows/reusable_macos.yml
with:
target: 'x86_64-apple-darwin'
build_type: 'release'
run_tests: false



4 changes: 1 addition & 3 deletions .github/workflows/reusable_linux.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Reusable workflow for testing on linux
name: Reusable workflow for linux

on:
workflow_call:
Expand Down Expand Up @@ -90,7 +90,6 @@ jobs:
with:
name: upload-binary-artifact
path: |
rmate_${{ inputs.target }}.zip
rmate_${{ inputs.target }}.tar.gz
if-no-files-found: warn

Expand All @@ -107,5 +106,4 @@ jobs:
with:
fail_on_unmatched_files: false
files: |
rmate_${{ inputs.target }}.zip
rmate_${{ inputs.target }}.tar.gz
90 changes: 90 additions & 0 deletions .github/workflows/reusable_macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Reusable workflow for macos

on:
workflow_call:
inputs:
target:
required: true
type: string
arm:
type: boolean
default: false
build_type:
type: string
default: 'debug'
run_tests:
type: boolean
default: true

env:
ARM: ${{ inputs.arm }}
TARGET: ${{ inputs.target }}
BUILD_TYPE: ${{ inputs.build_type }}
RELEASE_COMMIT: ${{ github.ref_type == 'tag' }}

jobs:
build_binary:
name: rust-${{ matrix.rust }} (${{ inputs.build_type }})
strategy:
matrix:
os: [macos-latest]
rust: [1.56.0, stable]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install pcregrep
run: |
brew install pcre2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ inputs.target }}
override: true
- name: Build binary (debug)
if: ${{ inputs.build_type == 'debug' }}
uses: actions-rs/cargo@v1
with:
command: build
args: --target ${{ inputs.target }}
- name: Build binary (release)
if: ${{ inputs.build_type == 'release' }}
uses: actions-rs/cargo@v1
with:
command: build
args: --target ${{ inputs.target }} --release
- name: Run test
if: ${{ inputs.run_tests }}
run: .github/workflows/run_test.sh

- name: Prepare release artifact
if: ${{ github.ref_type == 'tag' && matrix.rust == 'stable' }}
run: |
.github/workflows/prepare_artifact.sh
- name: Upload for release
id: upload_artifact
uses: actions/upload-artifact@v2
if: ${{ github.ref_type == 'tag' && matrix.rust == 'stable' }}
with:
name: upload-binary-artifact
path: |
rmate_${{ inputs.target }}.zip
if-no-files-found: warn

release_binary:
name: Release rmate
runs-on: ubuntu-latest
needs: build_binary
if: ${{ github.ref_type == 'tag' }}
steps:
- uses: actions/download-artifact@v2
with:
name: upload-binary-artifact
- uses: softprops/action-gh-release@v1
with:
fail_on_unmatched_files: false
files: |
rmate_${{ inputs.target }}.zip
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use settings::OpenedBuffer;
use settings::Settings;
use structopt::StructOpt;

// TODO: Build universal binary for macos on github actions.

#[allow(clippy::option_map_unit_fn)]
fn main() -> Result<(), String> {
// Read settings from cmd line arguments
Expand Down

0 comments on commit 38bcc6b

Please sign in to comment.