Skip to content

Commit 5129b96

Browse files
authored
Release 0.0.1 (#3)
- Bump version: 0.0.0 → 0.0.1 - Update changelog - Update changelog contributor credits - Update dependencies - Add release recipes to justfile - Add release workflow - Add package script
1 parent 18c5f84 commit 5129b96

File tree

11 files changed

+288
-9
lines changed

11 files changed

+288
-9
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ jobs:
3232
- uses: Swatinem/rust-cache@v2
3333

3434
- name: Clippy
35-
run: cargo clippy --all-targets
35+
run: cargo clippy --workspace --all-targets
3636

3737
- name: Format
38-
run: cargo fmt -- --check
38+
run: cargo fmt --all -- --check
3939

4040
- name: Check for Forbidden Words
4141
run: |
@@ -64,4 +64,4 @@ jobs:
6464
- uses: Swatinem/rust-cache@v2
6565

6666
- name: Test
67-
run: cargo test
67+
run: cargo test --workspace

.github/workflows/release.yaml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Release
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
push:
8+
tags:
9+
- '*'
10+
11+
defaults:
12+
run:
13+
shell: bash
14+
15+
jobs:
16+
release:
17+
strategy:
18+
matrix:
19+
target:
20+
- aarch64-apple-darwin
21+
- aarch64-pc-windows-msvc
22+
- aarch64-unknown-linux-musl
23+
- arm-unknown-linux-musleabihf
24+
- armv7-unknown-linux-musleabihf
25+
- x86_64-apple-darwin
26+
- x86_64-pc-windows-msvc
27+
- x86_64-unknown-linux-musl
28+
include:
29+
- target: aarch64-apple-darwin
30+
os: macos-latest
31+
target_rustflags: ''
32+
- target: aarch64-pc-windows-msvc
33+
os: windows-latest
34+
target_rustflags: ''
35+
- target: aarch64-unknown-linux-musl
36+
os: ubuntu-latest
37+
target_rustflags: '--codegen linker=aarch64-linux-gnu-gcc'
38+
- target: arm-unknown-linux-musleabihf
39+
os: ubuntu-latest
40+
target_rustflags: '--codegen linker=arm-linux-gnueabihf-gcc'
41+
- target: armv7-unknown-linux-musleabihf
42+
os: ubuntu-latest
43+
target_rustflags: '--codegen linker=arm-linux-gnueabihf-gcc'
44+
- target: x86_64-apple-darwin
45+
os: macos-latest
46+
target_rustflags: ''
47+
- target: x86_64-pc-windows-msvc
48+
os: windows-latest
49+
- target: x86_64-unknown-linux-musl
50+
os: ubuntu-latest
51+
target_rustflags: ''
52+
53+
runs-on: ${{matrix.os}}
54+
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
- name: Install AArch64 Toolchain
59+
if: ${{ matrix.target == 'aarch64-unknown-linux-musl' }}
60+
run: |
61+
sudo apt-get update
62+
sudo apt-get install gcc-aarch64-linux-gnu libc6-dev-i386
63+
64+
- name: Install ARM Toolchain
65+
if: ${{ matrix.target == 'arm-unknown-linux-musleabihf' || matrix.target == 'armv7-unknown-linux-musleabihf' }}
66+
run: |
67+
sudo apt-get update
68+
sudo apt-get install gcc-arm-linux-gnueabihf
69+
70+
- name: Install AArch64 Toolchain (Windows)
71+
if: ${{ matrix.target == 'aarch64-pc-windows-msvc' }}
72+
run: |
73+
rustup target add aarch64-pc-windows-msvc
74+
75+
- name: Release Type
76+
id: release-type
77+
run: |
78+
if [[ ${{ github.ref }} =~ ^refs/tags/[0-9]+[.][0-9]+[.][0-9]+$ ]]; then
79+
echo ::set-output name=value::release
80+
else
81+
echo ::set-output name=value::prerelease
82+
fi
83+
84+
- name: Package
85+
id: package
86+
env:
87+
TARGET: ${{ matrix.target }}
88+
REF: ${{ github.ref }}
89+
OS: ${{ matrix.os }}
90+
TARGET_RUSTFLAGS: ${{ matrix.target_rustflags }}
91+
run: ./bin/package
92+
shell: bash
93+
94+
- name: Publish Archive
95+
uses: softprops/[email protected]
96+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
97+
with:
98+
draft: false
99+
files: |
100+
${{ steps.package.outputs.archive }}
101+
${{ steps.package.outputs.archive }}.sha256sum
102+
prerelease: ${{ steps.release-type.outputs.value == 'prerelease' }}
103+
env:
104+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105+
106+
- name: Publish Changelog
107+
uses: softprops/[email protected]
108+
if: >-
109+
${{
110+
startsWith(github.ref, 'refs/tags/')
111+
&& matrix.target == 'x86_64-unknown-linux-musl'
112+
}}
113+
with:
114+
draft: false
115+
files: CHANGELOG.md
116+
prerelease: ${{ steps.ref-type.outputs.value != 'release' }}
117+
env:
118+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/target
2+
/tmp

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Changelog
2+
=========
3+
4+
[0.0.1](https://github.com/casey/filepack/releases/tag/0.0.1) - 2024-09-02
5+
--------------------------------------------------------------------------
6+
7+
### Added
8+
- Add create and verify subcommands ([#2](https://github.com/casey/filepack/pull/2) by [casey](https://github.com/casey))
9+
10+
### Misc
11+
- Initialize rust binary ([#1](https://github.com/casey/filepack/pull/1) by [casey](https://github.com/casey))

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "filepack"
3-
version = "0.0.0"
3+
version = "0.0.1"
44
authors = ["Casey Rodarmor <[email protected]>"]
55
autotests = false
66
description = "🗄️ file verification utility"
@@ -30,6 +30,9 @@ pedantic = { level = "deny", priority = -1 }
3030
result-large-err = "allow"
3131
wildcard_imports = "allow"
3232

33+
[workspace]
34+
members = [".", "crates/*"]
35+
3336
[[test]]
3437
name = "integration"
3538
path = "tests/lib.rs"

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,20 @@ in a manifest file named `filepack.json`.
1515
Files can later be verified against the hashes saved in the manifest to protect
1616
against accidental or malicious corruption, as long as the manifest has not
1717
been tampered with.
18+
19+
New Releases
20+
------------
21+
22+
New releases of `filepack` are made frequently so that users quickly get access to
23+
new features.
24+
25+
Release commit messages use the following template:
26+
27+
```
28+
Release x.y.z
29+
30+
- Bump version: x.y.z → x.y.z
31+
- Update changelog
32+
- Update changelog contributor credits
33+
- Update dependencies
34+
```

bin/package

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
3+
set -euxo pipefail
4+
5+
VERSION=${REF#"refs/tags/"}
6+
DIST=`pwd`/dist
7+
8+
echo "Packaging filepack $VERSION for $TARGET..."
9+
10+
test -f Cargo.lock || cargo generate-lockfile
11+
12+
echo "Installing rust toolchain for $TARGET..."
13+
rustup target add $TARGET
14+
15+
if [[ $TARGET == aarch64-unknown-linux-musl ]]; then
16+
export CC=aarch64-linux-gnu-gcc
17+
fi
18+
19+
echo "Building filepack..."
20+
RUSTFLAGS="--deny warnings --codegen target-feature=+crt-static $TARGET_RUSTFLAGS" \
21+
cargo build --bin filepack --target $TARGET --release
22+
EXECUTABLE=target/$TARGET/release/filepack
23+
24+
if [[ $OS == windows-latest ]]; then
25+
EXECUTABLE=$EXECUTABLE.exe
26+
fi
27+
28+
echo "Copying release files..."
29+
mkdir dist
30+
cp -r \
31+
$EXECUTABLE \
32+
Cargo.lock \
33+
Cargo.toml \
34+
LICENSE \
35+
CONTRIBUTING \
36+
README.md \
37+
$DIST
38+
39+
cd $DIST
40+
echo "Creating release archive..."
41+
case $OS in
42+
ubuntu-latest | macos-latest)
43+
ARCHIVE=$DIST/filepack-$VERSION-$TARGET.tar.gz
44+
tar czf $ARCHIVE *
45+
echo "archive=$ARCHIVE" >> $GITHUB_OUTPUT
46+
shasum -a 256 $ARCHIVE > $ARCHIVE.sha256sum
47+
;;
48+
windows-latest)
49+
ARCHIVE=$DIST/filepack-$VERSION-$TARGET.zip
50+
7z a $ARCHIVE *
51+
echo "archive=`pwd -W`/filepack-$VERSION-$TARGET.zip" >> $GITHUB_OUTPUT
52+
sha256sum $ARCHIVE > $ARCHIVE.sha256sum
53+
;;
54+
esac

crates/update-contributors/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "update-contributors"
3+
version = "0.0.0"
4+
edition = "2021"
5+
publish = false
6+
7+
[dependencies]
8+
regex = "1.5.4"
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
use {
2+
regex::{Captures, Regex},
3+
std::{fs, process::Command, str},
4+
};
5+
6+
fn author(pr: u64) -> String {
7+
eprintln!("#{pr}");
8+
let output = Command::new("sh")
9+
.args([
10+
"-c",
11+
&format!("gh pr view {pr} --json author | jq -r .author.login"),
12+
])
13+
.output()
14+
.unwrap();
15+
16+
assert!(
17+
output.status.success(),
18+
"{}",
19+
String::from_utf8_lossy(&output.stderr)
20+
);
21+
22+
str::from_utf8(&output.stdout).unwrap().trim().to_owned()
23+
}
24+
25+
fn main() {
26+
fs::write(
27+
"CHANGELOG.md",
28+
&*Regex::new(r"\(#(\d+)( by @[a-z]+)?\)")
29+
.unwrap()
30+
.replace_all(
31+
&fs::read_to_string("CHANGELOG.md").unwrap(),
32+
|captures: &Captures| {
33+
let pr = captures[1].parse().unwrap();
34+
let contributor = author(pr);
35+
format!("([#{pr}](https://github.com/casey/filepack/pull/{pr}) by [{contributor}](https://github.com/{contributor}))")
36+
},
37+
),
38+
)
39+
.unwrap();
40+
}

0 commit comments

Comments
 (0)