Skip to content

Commit c162df8

Browse files
authored
Distribute standalone binaries (#1)
1 parent 435de6a commit c162df8

File tree

6 files changed

+109
-27
lines changed

6 files changed

+109
-27
lines changed

.github/workflows/ci.yml

Lines changed: 78 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,16 @@ jobs:
4848
command: pre-commit run --all-files --show-diff-on-failure
4949

5050
build:
51-
name: Build
52-
runs-on: ubuntu-latest
51+
name: Build hledger-fmt
52+
runs-on: ${{ matrix.runs-on }}
53+
strategy:
54+
fail-fast: false
55+
matrix:
56+
runs-on:
57+
- ubuntu-latest
58+
- macos-14 # ARM
59+
- macos-13 # X86
60+
- windows-latest
5361
steps:
5462
- uses: actions/checkout@v4
5563
- name: Setup Rust
@@ -59,6 +67,61 @@ jobs:
5967
profile: minimal
6068
- name: Build
6169
run: cargo build --release
70+
- name: Standarize Windows executable path
71+
if: matrix.runs-on == 'windows-latest'
72+
run: mv target/release/hledger-fmt.exe target/release/hledger-fmt
73+
- uses: actions/upload-artifact@v4
74+
with:
75+
name: ${{ matrix.runs-on }}-build
76+
path: ./target/release/hledger-fmt
77+
if-no-files-found: error
78+
overwrite: true
79+
80+
dist:
81+
name: Create distribution packages
82+
runs-on: ubuntu-latest
83+
needs: build
84+
steps:
85+
- name: Create directories
86+
run: mkdir -p dist build/mac build/linux build/windows
87+
- name: Download MacOS ARM artifact
88+
uses: actions/download-artifact@v4
89+
with:
90+
name: macos-14-build
91+
path: ./build/mac-arm64
92+
- name: Download MacOS X86 artifact
93+
uses: actions/download-artifact@v4
94+
with:
95+
name: macos-13-build
96+
path: ./build/mac-x64
97+
- name: Download Linux artifact
98+
uses: actions/download-artifact@v4
99+
with:
100+
name: ubuntu-latest-build
101+
path: ./build/linux
102+
- name: Download Windows artifact
103+
uses: actions/download-artifact@v4
104+
with:
105+
name: windows-latest-build
106+
path: ./build/windows
107+
- name: Create Linux tarball
108+
run: tar -czf dist/hledger-fmt-linux-x64.tar.gz -C build/linux hledger-fmt
109+
- name: Create MacOS tarballs
110+
run: |
111+
tar -czf dist/hledger-fmt-mac-x64.tar.gz -C build/mac-x64 hledger-fmt
112+
tar -czf dist/hledger-fmt-mac-arm64.tar.gz -C build/mac-arm64 hledger-fmt
113+
- name: Create Windows zip
114+
run: |
115+
cd build/windows
116+
mv hledger-fmt hledger-fmt.exe
117+
7z a -tzip ../../dist/hledger-fmt-windows-x64.zip hledger-fmt.exe
118+
- name: Remove build directories
119+
run: rm -rf build
120+
- name: Upload artifacts
121+
uses: actions/upload-artifact@v4
122+
with:
123+
name: dist
124+
path: ./dist
62125

63126
unit-tests:
64127
name: Unit tests
@@ -92,7 +155,7 @@ jobs:
92155
needs:
93156
- qa
94157
- unit-tests
95-
- build
158+
- dist
96159
if: |
97160
'${{ github.event.pull_request.user.login }}' == 'mondeja' ||
98161
startsWith(github.ref, 'refs/tags/') ||
@@ -114,8 +177,7 @@ jobs:
114177
release:
115178
if: startsWith(github.ref, 'refs/tags/')
116179
name: Release heldger-fmt
117-
needs:
118-
- test-release
180+
needs: test-release
119181
runs-on: ubuntu-latest
120182
steps:
121183
- uses: actions/checkout@v4
@@ -132,8 +194,7 @@ jobs:
132194
create-release:
133195
if: startsWith(github.ref, 'refs/tags/')
134196
name: Create release
135-
needs:
136-
- release
197+
needs: release
137198
permissions:
138199
contents: write
139200
runs-on: ubuntu-latest
@@ -144,6 +205,11 @@ jobs:
144205
run: |
145206
TAG_TITLE=${GITHUB_REF#refs/*/}
146207
echo "title=$TAG_TITLE" >> $GITHUB_OUTPUT
208+
- name: Download distribution
209+
uses: actions/download-artifact@v4
210+
with:
211+
name: dist
212+
path: ./dist
147213
- name: Create release
148214
uses: softprops/action-gh-release@v2
149215
env:
@@ -155,3 +221,8 @@ jobs:
155221
See [CHANGELOG](https://github.com/mondeja/hledger-fmt/blob/master/CHANGELOG.md).
156222
draft: false
157223
prerelease: false
224+
files: |
225+
./dist/hledger-fmt-linux-x64.tar.gz
226+
./dist/hledger-fmt-mac-x64.tar.gz
227+
./dist/hledger-fmt-mac-arm64.tar.gz
228+
./dist/hledger-fmt-windows-x64.zip

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/target
22
.prettier-cache
3+
/dist/

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# CHANGELOG
22

3+
## 2024-09-28 - [0.1.3]
4+
5+
### Enhancements
6+
7+
- Provide standalone binaries for Windows X86_64 and Linux X86_64,
8+
MacOS X86_64 and MacOS ARM64.
9+
310
## 2024-09-27 - [0.1.2]
411

512
### Bug fixes
@@ -16,5 +23,6 @@
1623

1724
First beta release
1825

26+
[0.1.3]: https://github.com/mondeja/hledger-fmt/compare/v0.1.2...v0.1.3
1927
[0.1.2]: https://github.com/mondeja/hledger-fmt/compare/v0.1.1...v0.1.2
2028
[0.1.1]: https://github.com/mondeja/hledger-fmt/compare/v0.1.0...v0.1.1

Cargo.lock

Lines changed: 1 addition & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hledger-fmt"
3-
version = "0.1.2"
3+
version = "0.1.3"
44
edition = "2021"
55
description = "An opinionated hledger's journal files formatter."
66
repository = "https://github.com/mondeja/hledger-fmt"
@@ -25,14 +25,14 @@ path = "src/lib.rs"
2525
name = "hledger-fmt"
2626

2727
[dependencies]
28-
clap = { version = "4", features = ["derive"] }
28+
clap = { version = "4", default-features = false, features = ["std", "help", "derive"] }
2929
walkdir = "2"
3030
similar = "2"
3131
colored = { version = "2", optional = true }
3232

3333
[features]
3434
default = ["color"]
35-
color = ["dep:colored"]
35+
color = ["dep:colored", "clap/color"]
3636

3737
[workspace]
3838
members = ["."]

README.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
[![Crates.io](https://img.shields.io/crates/v/hledger-fmt?logo=rust)](https://crates.io/crates/hledger-fmt)
44
[![License](https://img.shields.io/crates/l/hledger-fmt)][license-badge-link]
55
[![Tests](https://img.shields.io/github/actions/workflow/status/mondeja/hledger-fmt/ci.yml?label=tests&logo=github)][tests-badge-link]
6-
[![Crates.io downloads](https://img.shields.io/crates/d/hledger-fmt)](https://crates.io/crates/hledger-fmt)
76

87
<!-- markdown-link-check-disable -->
98

@@ -16,19 +15,28 @@ An opinionated [hledger]'s journal files formatter.
1615

1716
## Installation
1817

19-
Build from source using [cargo]:
18+
[![Crates.io downloads](https://img.shields.io/crates/d/hledger-fmt?label=Crate%20downloads)](https://crates.io/crates/hledger-fmt)
19+
![GitHub downloads](https://img.shields.io/github/downloads/mondeja/hledger-fmt/total?label=GitHub%20downloads)
2020

21-
```bash
22-
cargo install hledger-fmt
23-
```
21+
### Standalone pre-built binaries
22+
23+
Download standalone pre-built binaries from [releases page].
24+
25+
### Cargo binaries
2426

2527
Install from pre-built binaries using [cargo-binstall]:
2628

27-
```bash
29+
```sh
2830
cargo binstall hledger-fmt
2931
```
3032

31-
We don't currently provide standalone pre-built binaries.
33+
### Build from source
34+
35+
Build from source using [cargo]:
36+
37+
```sh
38+
cargo install hledger-fmt
39+
```
3240

3341
### pre-commit
3442

@@ -49,7 +57,7 @@ When you don't pass files to format, it reads all the files with
4957
the extensions `.journal`, `.hledger` and `.j` in the current directory
5058
and its subdirectories.
5159

52-
```bash
60+
```sh
5361
hledger-fmt [OPTIONS] [FILES]...
5462
```
5563

@@ -59,7 +67,7 @@ To fix them in place, use the `--fix` option:
5967
> This is a potentially destructive operation. Make sure to make a backup
6068
> of your files before running this command for the first time.
6169

62-
```bash
70+
```sh
6371
hledger-fmt --fix [FILES]...
6472
```
6573

@@ -72,4 +80,5 @@ See `hledger-fmt --help` for more information.
7280
[cargo-binstall]: https://github.com/cargo-bins/cargo-binstall
7381
[hledger]: https://hledger.org
7482
[cargo]: https://doc.rust-lang.org/cargo/
83+
[releases page]: https://github.com/mondeja/hledger-fmt/releases
7584
[pre-commit]: https://pre-commit.com

0 commit comments

Comments
 (0)