Skip to content

Commit

Permalink
Release 0.0.1 (#3)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
casey authored Sep 3, 2024
1 parent 18c5f84 commit 5129b96
Show file tree
Hide file tree
Showing 11 changed files with 288 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ jobs:
- uses: Swatinem/rust-cache@v2

- name: Clippy
run: cargo clippy --all-targets
run: cargo clippy --workspace --all-targets

- name: Format
run: cargo fmt -- --check
run: cargo fmt --all -- --check

- name: Check for Forbidden Words
run: |
Expand Down Expand Up @@ -64,4 +64,4 @@ jobs:
- uses: Swatinem/rust-cache@v2

- name: Test
run: cargo test
run: cargo test --workspace
118 changes: 118 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Release

permissions:
contents: write

on:
push:
tags:
- '*'

defaults:
run:
shell: bash

jobs:
release:
strategy:
matrix:
target:
- aarch64-apple-darwin
- aarch64-pc-windows-msvc
- aarch64-unknown-linux-musl
- arm-unknown-linux-musleabihf
- armv7-unknown-linux-musleabihf
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
- x86_64-unknown-linux-musl
include:
- target: aarch64-apple-darwin
os: macos-latest
target_rustflags: ''
- target: aarch64-pc-windows-msvc
os: windows-latest
target_rustflags: ''
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
target_rustflags: '--codegen linker=aarch64-linux-gnu-gcc'
- target: arm-unknown-linux-musleabihf
os: ubuntu-latest
target_rustflags: '--codegen linker=arm-linux-gnueabihf-gcc'
- target: armv7-unknown-linux-musleabihf
os: ubuntu-latest
target_rustflags: '--codegen linker=arm-linux-gnueabihf-gcc'
- target: x86_64-apple-darwin
os: macos-latest
target_rustflags: ''
- target: x86_64-pc-windows-msvc
os: windows-latest
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
target_rustflags: ''

runs-on: ${{matrix.os}}

steps:
- uses: actions/checkout@v4

- name: Install AArch64 Toolchain
if: ${{ matrix.target == 'aarch64-unknown-linux-musl' }}
run: |
sudo apt-get update
sudo apt-get install gcc-aarch64-linux-gnu libc6-dev-i386
- name: Install ARM Toolchain
if: ${{ matrix.target == 'arm-unknown-linux-musleabihf' || matrix.target == 'armv7-unknown-linux-musleabihf' }}
run: |
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf
- name: Install AArch64 Toolchain (Windows)
if: ${{ matrix.target == 'aarch64-pc-windows-msvc' }}
run: |
rustup target add aarch64-pc-windows-msvc
- name: Release Type
id: release-type
run: |
if [[ ${{ github.ref }} =~ ^refs/tags/[0-9]+[.][0-9]+[.][0-9]+$ ]]; then
echo ::set-output name=value::release
else
echo ::set-output name=value::prerelease
fi
- name: Package
id: package
env:
TARGET: ${{ matrix.target }}
REF: ${{ github.ref }}
OS: ${{ matrix.os }}
TARGET_RUSTFLAGS: ${{ matrix.target_rustflags }}
run: ./bin/package
shell: bash

- name: Publish Archive
uses: softprops/[email protected]
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
draft: false
files: |
${{ steps.package.outputs.archive }}
${{ steps.package.outputs.archive }}.sha256sum
prerelease: ${{ steps.release-type.outputs.value == 'prerelease' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish Changelog
uses: softprops/[email protected]
if: >-
${{
startsWith(github.ref, 'refs/tags/')
&& matrix.target == 'x86_64-unknown-linux-musl'
}}
with:
draft: false
files: CHANGELOG.md
prerelease: ${{ steps.ref-type.outputs.value != 'release' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
/tmp
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Changelog
=========

[0.0.1](https://github.com/casey/filepack/releases/tag/0.0.1) - 2024-09-02
--------------------------------------------------------------------------

### Added
- Add create and verify subcommands ([#2](https://github.com/casey/filepack/pull/2) by [casey](https://github.com/casey))

### Misc
- Initialize rust binary ([#1](https://github.com/casey/filepack/pull/1) by [casey](https://github.com/casey))
9 changes: 8 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "filepack"
version = "0.0.0"
version = "0.0.1"
authors = ["Casey Rodarmor <[email protected]>"]
autotests = false
description = "🗄️ file verification utility"
Expand Down Expand Up @@ -30,6 +30,9 @@ pedantic = { level = "deny", priority = -1 }
result-large-err = "allow"
wildcard_imports = "allow"

[workspace]
members = [".", "crates/*"]

[[test]]
name = "integration"
path = "tests/lib.rs"
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,20 @@ in a manifest file named `filepack.json`.
Files can later be verified against the hashes saved in the manifest to protect
against accidental or malicious corruption, as long as the manifest has not
been tampered with.

New Releases
------------

New releases of `filepack` are made frequently so that users quickly get access to
new features.

Release commit messages use the following template:

```
Release x.y.z
- Bump version: x.y.z → x.y.z
- Update changelog
- Update changelog contributor credits
- Update dependencies
```
54 changes: 54 additions & 0 deletions bin/package
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash

set -euxo pipefail

VERSION=${REF#"refs/tags/"}
DIST=`pwd`/dist

echo "Packaging filepack $VERSION for $TARGET..."

test -f Cargo.lock || cargo generate-lockfile

echo "Installing rust toolchain for $TARGET..."
rustup target add $TARGET

if [[ $TARGET == aarch64-unknown-linux-musl ]]; then
export CC=aarch64-linux-gnu-gcc
fi

echo "Building filepack..."
RUSTFLAGS="--deny warnings --codegen target-feature=+crt-static $TARGET_RUSTFLAGS" \
cargo build --bin filepack --target $TARGET --release
EXECUTABLE=target/$TARGET/release/filepack

if [[ $OS == windows-latest ]]; then
EXECUTABLE=$EXECUTABLE.exe
fi

echo "Copying release files..."
mkdir dist
cp -r \
$EXECUTABLE \
Cargo.lock \
Cargo.toml \
LICENSE \
CONTRIBUTING \
README.md \
$DIST

cd $DIST
echo "Creating release archive..."
case $OS in
ubuntu-latest | macos-latest)
ARCHIVE=$DIST/filepack-$VERSION-$TARGET.tar.gz
tar czf $ARCHIVE *
echo "archive=$ARCHIVE" >> $GITHUB_OUTPUT
shasum -a 256 $ARCHIVE > $ARCHIVE.sha256sum
;;
windows-latest)
ARCHIVE=$DIST/filepack-$VERSION-$TARGET.zip
7z a $ARCHIVE *
echo "archive=`pwd -W`/filepack-$VERSION-$TARGET.zip" >> $GITHUB_OUTPUT
sha256sum $ARCHIVE > $ARCHIVE.sha256sum
;;
esac
8 changes: 8 additions & 0 deletions crates/update-contributors/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "update-contributors"
version = "0.0.0"
edition = "2021"
publish = false

[dependencies]
regex = "1.5.4"
40 changes: 40 additions & 0 deletions crates/update-contributors/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use {
regex::{Captures, Regex},
std::{fs, process::Command, str},
};

fn author(pr: u64) -> String {
eprintln!("#{pr}");
let output = Command::new("sh")
.args([
"-c",
&format!("gh pr view {pr} --json author | jq -r .author.login"),
])
.output()
.unwrap();

assert!(
output.status.success(),
"{}",
String::from_utf8_lossy(&output.stderr)
);

str::from_utf8(&output.stdout).unwrap().trim().to_owned()
}

fn main() {
fs::write(
"CHANGELOG.md",
&*Regex::new(r"\(#(\d+)( by @[a-z]+)?\)")
.unwrap()
.replace_all(
&fs::read_to_string("CHANGELOG.md").unwrap(),
|captures: &Captures| {
let pr = captures[1].parse().unwrap();
let contributor = author(pr);
format!("([#{pr}](https://github.com/casey/filepack/pull/{pr}) by [{contributor}](https://github.com/{contributor}))")
},
),
)
.unwrap();
}
28 changes: 24 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,39 @@ watch +args='test':
cargo watch --clear --exec '{{ args }}'

ci: lint
cargo test
cargo test --workspace

lint:
cargo clippy --all-targets -- --deny warnings
cargo clippy --workspace --all-targets -- --deny warnings
./bin/forbid
cargo fmt --all -- --check

outdated:
cargo outdated --root-deps-only
cargo outdated --workspace --root-deps-only

unused:
cargo +nightly udeps
cargo +nightly udeps --workspace

coverage:
cargo llvm-cov --html
open target/llvm-cov/html/index.html

update-changelog:
echo >> CHANGELOG.md
git log --pretty='format:- %s' >> CHANGELOG.md

update-contributors:
cargo run --release --package update-contributors

publish:
#!/usr/bin/env bash
set -euxo pipefail
rm -rf tmp/release
git clone [email protected]:casey/filepack.git tmp/release
cd tmp/release
VERSION=`sed -En 's/version[[:space:]]*=[[:space:]]*"([^"]+)"/\1/p' Cargo.toml | head -1`
git tag -a $VERSION -m "Release $VERSION"
git push origin $VERSION
cargo publish
cd ../..
rm -rf tmp/release

0 comments on commit 5129b96

Please sign in to comment.