Skip to content

Commit

Permalink
fix: github CI workflows for release and PR checks (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rendez committed Mar 13, 2023
1 parent 8028b3a commit c3b858c
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 8 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/compile_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Compile artifacts for target release

on:
release:
types: [created]

jobs:
release:
name: release ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-gnu
archive: zip
- target: x86_64-unknown-linux-musl
archive: tar.gz tar.xz tar.zst
- target: x86_64-apple-darwin
archive: zip

steps:
- uses: actions/checkout@v3
- name: Compile and release
uses: rust-build/rust-build.action@v1.4.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
RUSTTARGET: ${{ matrix.target }}
ARCHIVE_TYPES: ${{ matrix.archive }}
60 changes: 60 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Pull request prechecks

on:
pull_request:
branches: [main]

jobs:
precheck:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Install Stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Toolchain Info
run: |
rustup 1.25.2 --version
cargo --version --verbose
rustc --version
cargo clippy --version
- name: Conventional Commits
run: |
cargo install --locked cocogitto
cog check --from-latest-tag
- name: Lint
run: |
cargo fmt --check
cargo clippy
- name: Test
run: |
cargo check --locked
cargo test
build:
needs: precheck
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install Stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Build Default Target
run: |
cargo build --release
58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Bump version and release

on:
push:
branches: [main]

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Stable Minimal
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal

- name: Git User Setup
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Conventional Commits
run: |
cargo install --locked cocogitto
cog check --from-latest-tag
- name: Bump Package Version
run: |
cog bump --auto || exit 0
- name: Update Cargo.toml Version
id: versioning
run: |
version=$(git describe --tags "$(git rev-list --tags --max-count=1)")
echo "version=$version" >> "$GITHUB_OUTPUT"
sed -ri "s/version = \"(([0-9]+\.)*[0-9]+)\"/version = \"$version\"/" Cargo.toml
git add Cargo.toml
git commit --amend --no-edit
- name: Push
run: |
git push origin --tags
git push origin
- name: Release
uses: softprops/action-gh-release@v1
with:
body_path: CHANGELOG.md
draft: false
prerelease: false
tag_name: ${{ steps.versioning.outputs.version }}
token: ${{ secrets.PAT }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
Cargo.lock
.vscode
.DS_Store
2 changes: 0 additions & 2 deletions cog.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
tag_prefix = "v"

[changelog]
template = "remote"
remote = "github.com"
Expand Down
7 changes: 1 addition & 6 deletions src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ use crossterm::{
};
use std::io;

/// Failure-guarded setup and cleanup for the terminal.
///
/// Example:
/// ```
/// let mut _t = TerminalGuard::create();
/// ```
// Failure-guarded setup and cleanup for the terminal.
pub struct TerminalGuard;

impl TerminalGuard {
Expand Down

0 comments on commit c3b858c

Please sign in to comment.