-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
104 additions
and
134 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,107 @@ | ||
name: CD | ||
name: Release | ||
on: | ||
push: | ||
tags: | ||
- "v*.*.*" | ||
jobs: | ||
publish: | ||
name: Publishing for ${{ matrix.os }} | ||
build-release: | ||
runs-on: ${{ matrix.os }} | ||
permissions: write-all | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ macos-latest, ubuntu-latest, windows-latest ] | ||
rust: [ stable ] | ||
include: | ||
# Linux | ||
- os: ubuntu-latest | ||
target: x86_64-unknown-linux-musl | ||
archive: tar.gz | ||
archive-cmd: tar czf | ||
sha-cmd: sha256sum | ||
- os: ubuntu-latest | ||
target: aarch64-unknown-linux-musl | ||
archive: tar.gz | ||
archive-cmd: tar czf | ||
sha-cmd: sha256sum | ||
- os: ubuntu-latest | ||
target: arm-unknown-linux-musleabihf | ||
archive: tar.gz | ||
archive-cmd: tar czf | ||
sha-cmd: sha256sum | ||
- os: ubuntu-latest | ||
target: loongarch64-unknown-linux-gnu | ||
archive: tar.gz | ||
archive-cmd: tar czf | ||
sha-cmd: sha256sum | ||
|
||
# MacOS | ||
- os: macos-latest | ||
artifact_prefix: macos | ||
target: x86_64-apple-darwin | ||
binary_postfix: "" | ||
- os: ubuntu-latest | ||
artifact_prefix: linux | ||
target: x86_64-unknown-linux-gnu | ||
binary_postfix: "" | ||
archive: zip | ||
archive-cmd: zip -r | ||
sha-cmd: shasum -a 256 | ||
- os: macos-latest | ||
target: aarch64-apple-darwin | ||
archive: zip | ||
archive-cmd: zip -r | ||
sha-cmd: shasum -a 256 | ||
|
||
# Windows | ||
- os: windows-latest | ||
artifact_prefix: windows | ||
target: x86_64-pc-windows-msvc | ||
binary_postfix: ".exe" | ||
archive: zip | ||
archive-cmd: 7z a | ||
sha-cmd: sha256sum | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Installing Rust toolchain | ||
uses: actions-rs/toolchain@v1 | ||
uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
override: true | ||
- name: Installing needed macOS dependencies | ||
if: matrix.os == 'macos-latest' | ||
run: brew install [email protected] | ||
- name: Installing needed Ubuntu dependencies | ||
target: ${{ matrix.target }} | ||
toolchain: stable | ||
|
||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Build for Linux | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y -qq pkg-config libssl-dev libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev | ||
- name: Checking out sources | ||
uses: actions/checkout@v1 | ||
- name: Running cargo build | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
toolchain: ${{ matrix.rust }} | ||
args: --release --target ${{ matrix.target }} | ||
cargo install cross --git https://github.com/cross-rs/cross | ||
cross build --release --target ${{ matrix.target }} | ||
- name: Build for Darwin and Windows | ||
if: matrix.os == 'macos-latest' || matrix.os == 'windows-latest' | ||
run: cargo build --release --target ${{ matrix.target }} | ||
|
||
- name: Packaging final binary | ||
- name: Packaging final binaries | ||
shell: bash | ||
run: | | ||
cd target/${{ matrix.target }}/release | ||
BINARY_NAME=tuistash${{ matrix.binary_postfix }} | ||
strip $BINARY_NAME | ||
RELEASE_NAME=tuistash-${{ matrix.artifact_prefix }} | ||
tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME | ||
if [[ ${{ runner.os }} == 'Windows' ]]; then | ||
certutil -hashfile $RELEASE_NAME.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > $RELEASE_NAME.sha256 | ||
src=$(pwd) | ||
stage=$(mktemp -d) | ||
ver=${GITHUB_REF#refs/tags/} | ||
asset_name="tuistash-$ver-${{ matrix.target }}.${{ matrix.archive }}" | ||
ASSET_PATH="$src/$asset_name" | ||
CHECKSUM_PATH="$ASSET_PATH.sha256" | ||
cp target/${{ matrix.target }}/release/tuistash $stage/ | ||
cd $stage | ||
${{ matrix.archive-cmd }} $ASSET_PATH * | ||
cd $src | ||
${{ matrix.sha-cmd }} $asset_name > $CHECKSUM_PATH | ||
if [ "$RUNNER_OS" == "Windows" ]; then | ||
echo "ASSET_PATH=$(cygpath -m $ASSET_PATH)" >> $GITHUB_ENV | ||
echo "CHECKSUM_PATH=$(cygpath -m $CHECKSUM_PATH)" >> $GITHUB_ENV | ||
else | ||
shasum -a 256 $RELEASE_NAME.tar.gz > $RELEASE_NAME.sha256 | ||
echo "ASSET_PATH=$ASSET_PATH" >> $GITHUB_ENV | ||
echo "CHECKSUM_PATH=$CHECKSUM_PATH" >> $GITHUB_ENV | ||
fi | ||
- name: Releasing assets | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
fail_on_unmatched_files: true | ||
files: | | ||
target/${{ matrix.target }}/release/tuistash-${{ matrix.artifact_prefix }}.tar.gz | ||
target/${{ matrix.target }}/release/tuistash-${{ matrix.artifact_prefix }}.sha256 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Extract version | ||
id: extract-version | ||
run: | | ||
printf "::set-output name=%s::%s\n" tag-name "${GITHUB_REF#refs/tags/}" | ||
- name: Bump Homebrew formula | ||
uses: mislav/bump-homebrew-formula-action@v2 | ||
if: "matrix.os == 'macos-latest' && !contains(github.ref, '-')" # skip pre-releases | ||
with: | ||
formula-name: tuistash | ||
formula-path: Formula/tuistash.rb | ||
homebrew-tap: edmocosta/homebrew-tap | ||
base-branch: main | ||
download-url: https://github.com/edmocosta/tuistash/releases/download/${{ steps.extract-version.outputs.tag-name }}/tuistash-macos.tar.gz | ||
commit-message: | | ||
{{formulaName}} {{version}} | ||
${{ env.ASSET_PATH }} | ||
${{ env.CHECKSUM_PATH }} | ||
env: | ||
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,44 @@ | ||
on: | ||
pull_request: | ||
push: | ||
branches: main | ||
branches: | ||
- main | ||
|
||
name: CI | ||
jobs: | ||
# Skip based on commit message `[skip ci]` | ||
# Source https://gist.github.com/ybiquitous/c80f15c18319c63cae8447a3be341267 | ||
prepare: | ||
runs-on: ubuntu-latest | ||
if: | | ||
!contains(format('{0} {1} {2}', github.event.head_commit.message, github.event.pull_request.title, github.event.pull_request.body), '[skip ci]') | ||
steps: | ||
- run: | | ||
cat <<'MESSAGE' | ||
github.event_name: ${{ toJson(github.event_name) }} | ||
github.event: | ||
${{ toJson(github.event) }} | ||
MESSAGE | ||
check: | ||
name: Check | ||
runs-on: ubuntu-latest | ||
needs: prepare | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
profile: minimal | ||
override: true | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: check | ||
|
||
# Commented for now (no tests implemented yet) | ||
# test: | ||
# name: Test Suite | ||
# runs-on: ubuntu-latest | ||
# needs: prepare | ||
# steps: | ||
# - uses: actions/checkout@master | ||
# - uses: actions-rs/toolchain@v1 | ||
# with: | ||
# toolchain: stable | ||
# profile: minimal | ||
# override: true | ||
# - run: sudo apt-get install -y -qq libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev | ||
# - uses: Swatinem/rust-cache@v1 | ||
# - uses: actions-rs/cargo@v1 | ||
# with: | ||
# command: test | ||
|
||
fmt: | ||
name: Rustfmt | ||
runs-on: ubuntu-latest | ||
needs: prepare | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: actions-rs/toolchain@v1 | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@nightly | ||
with: | ||
toolchain: stable | ||
profile: minimal | ||
override: true | ||
components: rustfmt | ||
- uses: Swatinem/rust-cache@v1 | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: fmt | ||
args: --all -- --check | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: cargo fmt --all -- --check | ||
|
||
clippy: | ||
name: Clippy | ||
runs-on: ubuntu-latest | ||
needs: prepare | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: actions-rs/toolchain@v1 | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
with: | ||
toolchain: stable | ||
profile: minimal | ||
override: true | ||
components: clippy | ||
- uses: Swatinem/rust-cache@v1 | ||
- uses: actions-rs/cargo@v1 | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: cargo clippy --all-targets --all-features -- -D warnings | ||
|
||
test: | ||
name: Test | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ ubuntu-latest, windows-latest, macOS-latest ] | ||
rust: [ stable, beta, nightly ] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@master | ||
with: | ||
command: clippy | ||
args: -- -D warnings | ||
toolchain: ${{ matrix.rust }} | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: cargo test --all-features |
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