Skip to content

Commit

Permalink
chore: publish aur releases
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Sep 27, 2024
1 parent 5f1f92c commit ae17dfc
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 11 deletions.
38 changes: 34 additions & 4 deletions .github/workflows/publish-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ concurrency:
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
NPM_CONFIG_FUND: false
DRY_RUN: ${{ !startsWith(github.ref, 'refs/tags/v') }}

jobs:
publish-cli:
build:
strategy:
matrix:
include:
- target: universal-apple-darwin
os: macos-14
os: macos-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-unknown-linux-musl
Expand All @@ -33,20 +35,31 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: jdx/mise-action@v2
with:
experimental: true
- if: matrix.os == 'macos'
uses: apple-actions/import-codesign-certs@v3
with:
p12-file-base64: ${{ secrets.APPLE_DEVELOPER_ID_APPLICATION_CERTS_P12 }}
p12-password: ${{ secrets.APPLE_DEVELOPER_ID_APPLICATION_CERTS_P12_PASS }}
- uses: taiki-e/upload-rust-binary-action@v1
with:
bin: usage
token: ${{ secrets.GITHUB_TOKEN }}
target: ${{ matrix.target }}
manifest-path: cli/Cargo.toml
dry_run: ${{ startsWith(github.ref, 'refs/tags/v') }}
codesign: true
codesign_prefix: dev.jdx.
env:
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 1
CARGO_PROFILE_RELEASE_LTO: true
bump-homebrew-formula:
runs-on: macos-14
runs-on: macos-latest
timeout-minutes: 10
needs: [publish-cli]
continue-on-error: true
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
steps:
- name: Bump Homebrew formula
uses: dawidd6/action-homebrew-bump-formula@v3
Expand All @@ -59,3 +72,20 @@ jobs:
token: ${{ secrets.GH_BOT_TOKEN }}
formula: usage
tap: jdx/homebrew-tap
bump-aur:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: jdx/mise-action@v2
with:
experimental: true
- uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.AUR_SSH_KEY }}
known_hosts: ${{ secrets.AUR_KNOWN_HOSTS }}
- uses: actions/download-artifact@v4
with:
pattern: usage-*.tar.gz
merge-multiple: true
- run: mise run bump-aur usage
- run: mise run bump-aur usage-bin
3 changes: 3 additions & 0 deletions .github/workflows/release-plz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
- main
- release-plz

env:
NPM_CONFIG_FUND: false

concurrency:
group: release-plz

Expand Down
1 change: 1 addition & 0 deletions .idea/vcs.xml

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

127 changes: 127 additions & 0 deletions .mise/tasks/bump-aur
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#!/usr/bin/env bash
set -euxo pipefail
#USAGE arg "pkgname"
env

USAGE_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "usage-cli") | .version')

if [ ! -d aur ]; then
git clone ssh://aur@aur.archlinux.org/usage.git aur
fi
git -C aur pull

if [ "$usage_pkgname" == "usage" ]; then
SOURCE_SHA512=$(curl -fsSL "https://github.com/jdx/usage/archive/$USAGE_VERSION.tar.gz" | sha512sum | awk '{print $1}')
SHA512="$SOURCE_SHA512"
cat >aur/PKGBUILD <<EOF
# Maintainer: Jeff Dickey <releases-usage at jdx dot dev>
pkgname=usage
pkgver=${USAGE_VERSION#v*}
pkgrel=1
pkgdesc='A specification for CLIs'
arch=('x86_64')
url='https://github.com/jdx/usage'
license=('MIT')
makedepends=('cargo')
provides=('usage')
source=("\$pkgname-\$pkgver.tar.gz::https://github.com/jdx/\$pkgname/archive/v\$pkgver.tar.gz")
sha512sums=('$SOURCE_SHA512')
prepare() {
cd "\$srcdir/\$pkgname-\$pkgver"
cargo fetch --locked --target "\$CARCH-unknown-linux-gnu"
}
build() {
cd "\$srcdir/\$pkgname-\$pkgver"
export RUSTUP_TOOLCHAIN=stable
export CARGO_TARGET_DIR=target
cargo build --frozen --release --bin usage
}
package() {
cd "\$srcdir/\$pkgname-\$pkgver"
install -Dm755 target/release/usage "\$pkgdir/usr/bin/usage"
}
check() {
cd "\$srcdir/\$pkgname-\$pkgver"
./target/release/usage --version
}
EOF
cat >aur/.SRCINFO <<EOF
pkgbase = usage
pkgdesc = A specification for CLIs
pkgver = ${USAGE_VERSION#v*}
pkgrel = 1
url = https://github.com/jdx/usage
arch = x86_64
license = MIT
makedepends = cargo
provides = usage
source = usage-${USAGE_VERSION#v*}.tar.gz::https://github.com/jdx/usage/archive/$USAGE_VERSION.tar.gz
sha512sums = $SHA512
pkgname = usage
EOF
elif [ "$usage_pkgname" == "usage-bin" ]; then
SHA512=$(curl -fsSL "https://github.com/jdx/usage/archive/$USAGE_VERSION.tar.gz" | sha512sum | awk '{print $1}')
cat >aur/PKGBUILD <<EOF
# Maintainer: Jeff Dickey <releases-usage at jdx dot dev>
pkgname=usage-bin
pkgver=${USAGE_VERSION#v*}
pkgrel=1
pkgdesc='A specification for CLIs'
arch=('x86_64')
url='https://github.com/jdx/usage'
license=('MIT')
makedepends=('cargo')
provides=('usage')
source=("usage-\$pkgver.tar.gz::https://github.com/jdx/usage/releases/download/v\$pkgver/usage-x86_64-unknown-linux-gnu.tar.gz")
sha512sums=('$SHA512')
build() {
cd "\$srcdir/"
}
package() {
cd "\$srcdir/"
install -Dm755 usage "\$pkgdir/usr/bin/usage"
}
check() {
"\$srcdir/usage" --version
}
EOF
cat >aur/.SRCINFO <<EOF
pkgbase = usage-bin
pkgdesc = A specification for CLIs
pkgver = ${USAGE_VERSION#v*}
pkgrel = 1
url = https://github.com/jdx/usage
arch = x86_64
license = MIT
makedepends = cargo
provides = usage
source = usage-${USAGE_VERSION#v*}.tar.gz::https://github.com/jdx/usage/releases/download/$USAGE_VERSION/usage-x86_64-unknown-linux-gnu.tar.gz
sha512sums = $SHA512
pkgname = usage-bin
EOF
fi

cd aur
git config user.name jdx
git config user.email 216188+jdx@users.noreply.github.com
git add .SRCINFO PKGBUILD
if git diff-index --quiet HEAD --; then
echo "No changes to PKGBUILD or .SRCINFO"
exit 0
fi
git diff --cached
git commit -m "usage ${USAGE_VERSION#v}"
if [ "$DRY_RUN" == 0 ]; then
git push
fi
15 changes: 8 additions & 7 deletions .mise.toml → mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ _.path = ["./target/debug"]
"npm:prettier" = "latest"
"cargo:cargo-edit" = "latest"
"cargo:git-cliff" = "latest"
github-cli = "latest"

[tasks.build]
sources = ['{cli/,}src/**/*.rs', '{cli/,}Cargo.toml']
Expand Down Expand Up @@ -49,8 +50,8 @@ run = 'cargo fmt --all -- --check'

[tasks.lint-fix]
run = [
'cargo clippy --all --all-features --fix --allow-dirty --allow-staged -- -D warnings',
'cargo fmt --all',
'cargo clippy --all --all-features --fix --allow-dirty --allow-staged -- -D warnings',
'cargo fmt --all',
]

[tasks.format]
Expand All @@ -65,16 +66,16 @@ depends = ['render:*']
[tasks."render:mise-completions"]
depends = ['build']
run = [
'usage g completion bash mise --usage-cmd "@mise usage" > ~/src/mise/completions/mise.bash',
'usage g completion zsh mise --usage-cmd "@mise usage" > ~/src/mise/completions/_mise',
'usage g completion fish mise --usage-cmd "@mise usage" > ~/src/mise/completions/mise.fish',
'usage g completion bash mise --usage-cmd "@mise usage" > ~/src/mise/completions/mise.bash',
'usage g completion zsh mise --usage-cmd "@mise usage" > ~/src/mise/completions/_mise',
'usage g completion fish mise --usage-cmd "@mise usage" > ~/src/mise/completions/mise.fish',
]

[tasks."render:example-md"]
depends = ['build']
run = [
"usage g md examples/docs/MISE_INLINE.md",
"usage g md examples/docs/MISE_MULTI.md",
"usage g md examples/docs/MISE_INLINE.md",
"usage g md examples/docs/MISE_MULTI.md",
]

[tasks.release]
Expand Down
1 change: 1 addition & 0 deletions tasks

0 comments on commit ae17dfc

Please sign in to comment.