Skip to content

Commit

Permalink
Update workflows.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsully committed Jul 6, 2023
1 parent df45165 commit 5a60e89
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 59 deletions.
60 changes: 43 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,35 @@
name: Build

on:
workflow_dispatch:
push:
branches: [main]
pull_request:
branches: [main]
tags:
- v[0-9]+.[0-9]+.[0-9]+

env:
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"
RUST_BACKTRACE: 1

jobs:
build:
runs-on: macos-latest
strategy:
matrix:
include:
- name: Apple Silicon
target: aarch64-apple-darwin
arch: arm64
host: macos-latest
os: darwin
- name: Apple x86_64
target: x86_64-apple-darwin
arch: amd64
host: macos-latest
os: darwin

runs-on: ${{ matrix.host }}

steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -23,25 +39,35 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
targets: ${{ matrix.target }}
toolchain: stable

- uses: swatinem/rust-cache@v2
- uses: extractions/setup-just@v1

- name: Versions
run: |
git version
cargo version
- name: Format Check
run: just format-check
- name: Build
id: build
run: cargo build --release --target ${{ matrix.target }}

- name: Clippy
run: just lint
- name: Build archive name
id: archive_name
run: |
version=${{ github.ref_name }}
# [REPO_NAME]-[VERSION]-[OPERATING_SYSTEM]-[ARCHITECTURE].tar.gz
archive_name=${{ github.event.repository.name }}-${version#v}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz
echo "archive_name=${archive_name}" >> $GITHUB_ENV
- name: Build
- name: Archive release
id: archive
run: |
cargo build
tar --create --gzip --file=${{ env.archive_name }} --directory=./target/${{ matrix.target }}/release/ ${{ github.event.repository.name }}
shasum -a 256 ${{ env.archive_name }} > ${{ env.archive_name }}.sha256
- name: Test
run: cargo test
- name: Create draft release
uses: softprops/action-gh-release@v1
id: release
with:
files: |
${{ env.archive_name }}
${{ env.archive_name }}.sha256
draft: true
64 changes: 64 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_call:

env:
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"
RUST_BACKTRACE: 1

jobs:
build:
strategy:
matrix:
include:
- name: Apple Silicon
target: aarch64-apple-darwin
arch: arm64
host: macos-latest
os: darwin
- name: Apple x86_64
target: x86_64-apple-darwin
arch: amd64
host: macos-latest
os: darwin

runs-on: ${{ matrix.host }}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Rust Toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
targets: ${{ matrix.target }}
toolchain: stable

- uses: swatinem/rust-cache@v2
- uses: extractions/setup-just@v1

- name: Versions
run: |
git version
cargo version
- name: Format Check
run: just format-check

- name: Clippy
run: just lint

- name: Build & Test
id: build
run: |
cargo build --release --target ${{ matrix.target }}
cargo test
48 changes: 48 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
name: Publish

on:
workflow_dispatch:

jobs:
homebrew:
name: Publish to dsully/homebrew-tap
runs-on: ubuntu-latest
steps:
- name: Release my project to my Homebrew tap
uses: Justintime50/homebrew-releaser@v1
with:
homebrew_owner: dsully
homebrew_tap: homebrew-tap
formula_folder: Formula

commit_owner: Dan Sully
commit_email: [email protected]

github_token: ${{ secrets.HOMEBREW_GITHUB_TOKEN }}

install: |
bin.install "macos-defaults"
output = Utils.popen_read("#{bin}/macos-saves completions bash")
(bash_completion/"macos-defaults").write output
output = Utils.popen_read("#{bin}/macos-saves completions fish")
(fish_completion/"macos-defaults").write output
output = Utils.popen_read("#{bin}/macos-saves completions zsh")
(zsh_completion/"macos-defaults").write output
prefix.install_metafiles
test: |
system "macos-defaults -h"
target_darwin_amd64: true
target_darwin_arm64: true
target_linux_amd64: false
target_linux_arm64: false

update_readme_table: true

debug: true
42 changes: 0 additions & 42 deletions .github/workflows/release.yml

This file was deleted.

0 comments on commit 5a60e89

Please sign in to comment.