-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: automate the release publication
This still requires us to create a release commit, tag and push it.
- Loading branch information
Showing
3 changed files
with
167 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,156 @@ | ||
name: Release | ||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
jobs: | ||
# Build sources for every OS | ||
github_build: | ||
name: Build release binaries | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- target: x86_64-unknown-linux-gnu | ||
os: ubuntu-latest | ||
name: treefmt-x86_64-unknown-linux-gnu.tar.gz | ||
|
||
- target: x86_64-unknown-linux-musl | ||
os: ubuntu-latest | ||
name: treefmt-x86_64-unknown-linux-musl.tar.gz | ||
|
||
- target: i686-unknown-linux-musl | ||
os: ubuntu-latest | ||
name: treefmt-i686-unknown-linux-musl.tar.gz | ||
|
||
- target: aarch64-unknown-linux-musl | ||
os: ubuntu-latest | ||
name: treefmt-aarch64-unknown-linux-musl.tar.gz | ||
|
||
- target: arm-unknown-linux-musleabihf | ||
os: ubuntu-latest | ||
name: treefmt-arm-unknown-linux-musleabihf.tar.gz | ||
|
||
- target: x86_64-apple-darwin | ||
os: macOS-latest | ||
name: treefmt-x86_64-apple-darwin.tar.gz | ||
|
||
- target: aarch64-apple-darwin | ||
os: macOS-latest | ||
name: treefmt-aarch64-apple-darwin.tar.gz | ||
|
||
- target: x86_64-pc-windows-msvc | ||
os: windows-latest | ||
name: treefmt-x86_64-pc-windows-msvc.zip | ||
|
||
- target: i686-pc-windows-msvc | ||
os: windows-latest | ||
name: treefmt-i686-pc-windows-msvc.zip | ||
|
||
- target: aarch64-pc-windows-msvc | ||
os: windows-latest | ||
name: treefmt-aarch64-pc-windows-msvc.zip | ||
|
||
- target: x86_64-unknown-freebsd | ||
os: ubuntu-latest | ||
name: treefmt-x86_64-unknown-freebsd.tar.gz | ||
|
||
runs-on: ${{ matrix.os }} | ||
continue-on-error: true | ||
steps: | ||
- name: Setup | Checkout | ||
uses: actions/checkout@v2 | ||
|
||
# Cache files between builds | ||
- name: Setup | Cache Cargo | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
|
||
- name: Setup | Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
profile: minimal | ||
target: ${{ matrix.target }} | ||
|
||
- name: Build | Build | ||
uses: actions-rs/cargo@v1 | ||
# TODO: Remove this once it's the default | ||
env: | ||
SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk | ||
with: | ||
command: build | ||
args: --release --locked --target ${{ matrix.target }} | ||
use-cross: ${{ matrix.os == 'ubuntu-latest' }} | ||
|
||
- name: Post Build | Prepare artifacts [Windows] | ||
if: matrix.os == 'windows-latest' | ||
run: | | ||
cd target/${{ matrix.target }}/release | ||
strip treefmt.exe | ||
7z a ../../../${{ matrix.name }} treefmt.exe | ||
cd - | ||
- name: Post Build | Prepare artifacts [-nix] | ||
if: matrix.os != 'windows-latest' | ||
run: | | ||
cd target/${{ matrix.target }}/release | ||
# TODO: investigate better cross platform stripping | ||
strip treefmt || true | ||
tar czvf ../../../${{ matrix.name }} treefmt | ||
cd - | ||
- name: Deploy | Upload artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ matrix.name }} | ||
path: ${{ matrix.name }} | ||
|
||
# Create GitHub release with Rust build targets and release notes | ||
github_release: | ||
name: Create GitHub Release | ||
needs: github_build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup | Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup | Artifacts | ||
uses: actions/download-artifact@v2 | ||
|
||
- name: Setup | Checksums | ||
run: for file in treefmt-*/treefmt-*; do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done | ||
|
||
- name: Build | Publish | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: treefmt-*/treefmt-* | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Publish treefmt to Crates.io | ||
cargo_publish: | ||
name: Publish Cargo Package | ||
runs-on: ubuntu-latest | ||
needs: github_release | ||
steps: | ||
- name: Setup | Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup | Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
profile: minimal | ||
override: true | ||
|
||
- name: Build | Publish | ||
run: cargo publish --token ${{ secrets.CRATES_IO_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,15 +1,21 @@ | ||
[package] | ||
name = "treefmt" | ||
version = "0.2.0" | ||
edition = "2018" | ||
description = "one CLI to format the code tree" | ||
license = "MIT" | ||
authors = [ | ||
"Andika Demas Riyandi <[email protected]>", | ||
"Basile Henry <[email protected]>", | ||
"Jonas Chevalier <[email protected]>", | ||
] | ||
edition = "2018" | ||
description = "one CLI to format the code tree" | ||
license = "MIT" | ||
homepage = "https://numtide.github.io/treefmt" | ||
documentation = "https://numtide.github.io/treefmt" | ||
repository = "https://github.com/numtide/treefmt" | ||
readme = "README.md" | ||
keywords = ["formatting"] | ||
categories = ["command-line-utilities", "development-tools"] | ||
include = ["src/**/*", "/Cross.toml", "/LICENSE.md", "/README.md"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[target.x86_64-unknown-freebsd] | ||
image = "docker.io/rustembedded/cross:x86_64-unknown-freebsd" |