From 5a60e898f8f214e3950bf322c8b8058d7a27de54 Mon Sep 17 00:00:00 2001 From: Dan Sully Date: Thu, 6 Jul 2023 14:23:44 -0700 Subject: [PATCH] Update workflows. --- .github/workflows/build.yml | 60 ++++++++++++++++++++++---------- .github/workflows/ci.yml | 64 +++++++++++++++++++++++++++++++++++ .github/workflows/publish.yml | 48 ++++++++++++++++++++++++++ .github/workflows/release.yml | 42 ----------------------- 4 files changed, 155 insertions(+), 59 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b595034..ab8734c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..44586b9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..3ce871c --- /dev/null +++ b/.github/workflows/publish.yml @@ -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: dan+github@sully.org + + 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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 9c612e8..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,42 +0,0 @@ ---- -name: Release - -on: - push: - tags: - - v[0-9]+.* - -env: - CARGO_TERM_COLOR: always - RUSTFLAGS: "-D warnings" - RUST_BACKTRACE: 1 - -jobs: - create-release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: taiki-e/create-gh-release-action@v1 - # with: - # changelog: CHANGELOG.md - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - upload-assets: - strategy: - matrix: - include: - - target: aarch64-apple-darwin - os: macos-11 - - target: x86_64-apple-darwin - os: macos-11 - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v3 - - uses: taiki-e/upload-rust-binary-action@v1 - with: - target: ${{ matrix.target }} - bin: macos-defaults - tar: all - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}