Line buffer output in TUI mode #137
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# This workflow runs when PRs are merged and tags/builds/publishes a release. | |
# Run when PRs to main are closed. | |
on: | |
pull_request: | |
types: | |
- closed | |
branches: | |
- main | |
name: Build and publish a release | |
jobs: | |
# We make `if_merged` a `needs:` of the other jobs here to only run this | |
# workflow on merged PRs. | |
if_merged: | |
name: Check that PR was merged and not closed | |
if: github.event.pull_request.merged == true | |
&& contains(github.event.pull_request.labels.*.name, 'release') | |
runs-on: ubuntu-latest | |
steps: | |
- run: | | |
echo "This is a canonical hack to run GitHub Actions on merged PRs" | |
echo "See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-pull_request-workflow-when-a-pull-request-merges" | |
- name: Comment on PR with link to this action | |
uses: peter-evans/create-or-update-comment@v2 | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
[This release is now being built.][run] | |
[run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
version: | |
name: Get version number | |
needs: if_merged | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.get_cargo_metadata.outputs.version }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- uses: cachix/install-nix-action@v22 | |
with: | |
github_access_token: ${{ secrets.GITHUB_TOKEN }} | |
extra_nix_config: | | |
extra-experimental-features = nix-command flakes | |
accept-flake-config = true | |
- name: Get version number | |
id: get_cargo_metadata | |
run: echo "version=$(nix run .#get-crate-version)" >> "$GITHUB_OUTPUT" | |
build: | |
name: Release Build | |
# Now we're ready to do the release build. In this step, we upload | |
# "artifacts" which lets us share files between jobs (the artifacts are | |
# downloaded by the next job, `upload`) and aggregate files from different | |
# parts of the matrix (so we can have the macOS and Linux executables in | |
# the next job). | |
needs: if_merged | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Install rustup | |
uses: dtolnay/rust-toolchain@stable | |
if: runner.os == 'macOS' | |
with: | |
target: x86_64-apple-darwin, aarch64-apple-darwin | |
- name: Log versions | |
if: runner.os == 'macOS' | |
run: which -a rustup && rustup --version | |
- name: Build (macOS, x86_64) | |
if: runner.os == 'macOS' | |
# Nix cross-compilation is broken on macOS, but cargo works fine. | |
# See: https://github.com/NixOS/nixpkgs/issues/180771 | |
run: cargo build --release --target x86_64-apple-darwin | |
- name: Build (macOS, aarch64) | |
if: runner.os == 'macOS' | |
run: cargo build --release --target aarch64-apple-darwin | |
- name: Create macOS universal executable | |
if: runner.os == 'macOS' | |
run: | | |
lipo -create -output target/release/ghciwatch-macos \ | |
target/x86_64-apple-darwin/release/ghciwatch \ | |
target/aarch64-apple-darwin/release/ghciwatch | |
- uses: cachix/install-nix-action@v22 | |
if: runner.os == 'Linux' | |
with: | |
github_access_token: ${{ secrets.GITHUB_TOKEN }} | |
extra_nix_config: | | |
extra-experimental-features = nix-command flakes | |
accept-flake-config = true | |
- name: Create target directory (Linux) | |
if: runner.os == 'Linux' | |
run: mkdir -p target/ | |
- name: Build (Linux, x86_64) | |
if: runner.os == 'Linux' | |
run: | | |
mkdir -p target/ | |
RESULT=$(nix build --no-link --print-out-paths --print-build-logs .#ghciwatch) | |
cp "$RESULT/bin/ghciwatch" target/ghciwatch-x86_64-linux | |
- name: Build (Linux, aarch64) | |
if: runner.os == 'Linux' | |
run: | | |
RESULT=$(nix build --no-link --print-out-paths --print-build-logs .#ghciwatch-aarch64-linux) | |
cp "$RESULT/bin/ghciwatch" target/ghciwatch-aarch64-linux | |
- name: Upload macOS executable | |
uses: actions/upload-artifact@v3 | |
if: runner.os == 'macOS' | |
with: | |
name: macos | |
path: target/release/ghciwatch-macos | |
- name: Upload Linux executables | |
uses: actions/upload-artifact@v3 | |
if: runner.os == 'Linux' | |
with: | |
name: linux | |
path: | | |
target/ghciwatch-x86_64-linux | |
target/ghciwatch-aarch64-linux | |
- name: Publish to crates.io | |
if: runner.os == 'Linux' | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
run: | | |
nix run .#cargo -- publish --no-verify | |
upload: | |
name: Upload assets to release | |
runs-on: ubuntu-latest | |
needs: | |
- if_merged | |
- build | |
- version | |
steps: | |
- name: Tag the release | |
uses: mathieudutour/github-tag-action@v6.0 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
commit_sha: ${{ github.event.pull_request.merge_commit_sha }} | |
custom_tag: ${{ needs.version.outputs.version }} | |
- name: Download artifacts | |
# This downloads the uploaded artifacts to the current directory; the | |
# path format for downloaded artifacts is `{name}/{basename}`, where | |
# `{basename}` is the basename of the upload `path`. | |
# | |
# For example, the following artifact: | |
# | |
# - uses: actions/upload-artifact@v3 | |
# with: | |
# name: linux | |
# path: target/release/ghciwatch-aarch64-linux | |
# | |
# will be downloaded to `linux/ghciwatch-aarch64-linux`. | |
uses: actions/download-artifact@v3 | |
- name: Create release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
draft: false | |
prerelease: false | |
generate_release_notes: true | |
tag_name: v${{ needs.version.outputs.version }} | |
files: | | |
macos/ghciwatch-macos | |
linux/ghciwatch-x86_64-linux | |
linux/ghciwatch-aarch64-linux | |
- name: Comment on PR with link to the release | |
uses: peter-evans/create-or-update-comment@v2 | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
[Release ${{ needs.version.outputs.version }}][release] was built and published successfully! | |
[release]: ${{ steps.create_release.outputs.url }} |