-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Follow the example of houseabsolute/ubi to use cross-rs/cross to cross-compile binaries for multiple platforms and architectures. Use `musl` where available to support both `glibc` and `musl` Linux distributions. Test for every push against stable, beta, and nightly, and build archives that contain the license, readme, and change log, as well as the `pgxn_meta` binary. Also add a workflow to publish on crates.io, and add a dependency check step to the lint and test workflow. Add `CHANGELOG.md` for tracking changes, and update `Cargo.toml` for distribution on crates.io. Revise the README for the crate and binary.
- Loading branch information
Showing
7 changed files
with
337 additions
and
6 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,188 @@ | ||
name: 🚀 Build and Release | ||
on: | ||
push: | ||
branches-ignore: [wip/**] | ||
tags: ["**"] | ||
pull_request: | ||
env: | ||
CRATE_NAME: pgxn_meta | ||
GITHUB_TOKEN: ${{ github.token }} | ||
RUST_BACKTRACE: 1 | ||
permissions: | ||
contents: write | ||
jobs: | ||
release: | ||
name: ${{ matrix.platform.emoji }} ${{ matrix.platform.os_name }} 🦀 ${{ matrix.toolchain }} | ||
runs-on: ${{ matrix.platform.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: | ||
- os_name: freebsd-amd64 | ||
os: ubuntu-20.04 | ||
target: x86_64-unknown-freebsd | ||
bin: pgxn_meta | ||
emoji: 😈 | ||
skip_tests: true | ||
- os_name: linux-amd64 | ||
os: ubuntu-20.04 | ||
target: x86_64-unknown-linux-musl | ||
bin: pgxn_meta | ||
emoji: 🐧 | ||
- os_name: linux-arm64 | ||
os: ubuntu-20.04 | ||
target: aarch64-unknown-linux-musl | ||
bin: pgxn_meta | ||
emoji: 🐧 | ||
- os_name: linux-arm | ||
os: ubuntu-20.04 | ||
target: arm-unknown-linux-musleabi | ||
bin: pgxn_meta | ||
emoji: 🐧 | ||
- os_name: linux-i686 | ||
os: ubuntu-20.04 | ||
target: i686-unknown-linux-musl | ||
bin: pgxn_meta | ||
emoji: 🐧 | ||
- os_name: linux-powerpc | ||
os: ubuntu-20.04 | ||
target: powerpc-unknown-linux-gnu | ||
bin: pgxn_meta | ||
emoji: 🐧 | ||
- os_name: linux-powerpc64 | ||
os: ubuntu-20.04 | ||
target: powerpc64-unknown-linux-gnu | ||
bin: pgxn_meta | ||
emoji: 🐧 | ||
- os_name: linux-powerpc64le | ||
os: ubuntu-20.04 | ||
target: powerpc64le-unknown-linux-gnu | ||
bin: pgxn_meta | ||
emoji: 🐧 | ||
- os_name: linux-riscv64 | ||
os: ubuntu-20.04 | ||
target: riscv64gc-unknown-linux-gnu | ||
bin: pgxn_meta | ||
emoji: 🐧 | ||
- os_name: linux-s390x | ||
os: ubuntu-20.04 | ||
target: s390x-unknown-linux-gnu | ||
bin: pgxn_meta | ||
emoji: 🐧 | ||
- os_name: linux-sparc64 | ||
os: ubuntu-20.04 | ||
target: sparc64-unknown-linux-gnu | ||
bin: pgxn_meta | ||
emoji: 🐧 | ||
- os_name: netbsd-amd64 | ||
os: ubuntu-20.04 | ||
target: x86_64-unknown-netbsd | ||
bin: pgxn_meta | ||
emoji: ⛳️ | ||
skip_tests: true | ||
- os_name: windows-arm64 | ||
os: windows-latest | ||
target: aarch64-pc-windows-msvc | ||
bin: pgxn_meta.exe | ||
emoji: 🪟 | ||
skip_tests: true | ||
- os_name: windows-i686 | ||
os: windows-latest | ||
target: i686-pc-windows-msvc | ||
bin: pgxn_meta.exe | ||
emoji: 🪟 | ||
- os_name: windows-amd64 | ||
os: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
bin: pgxn_meta.exe | ||
emoji: 🪟 | ||
- os_name: darwin-amd64 | ||
os: darwin-latest | ||
target: x86_64-apple-darwin | ||
bin: pgxn_meta | ||
emoji: 🍎 | ||
- os_name: darwin-arm64 | ||
os: darwin-latest | ||
target: aarch64-apple-darwin | ||
bin: pgxn_meta | ||
emoji: 🍎 | ||
- os_name: illumos-amd64 | ||
os: ubuntu-20.04 | ||
target: x86_64-unknown-illumos | ||
bin: pgxn_meta | ||
emoji: 🐦🔥 | ||
skip_tests: true | ||
toolchain: | ||
- stable | ||
- beta | ||
- nightly | ||
exclude: | ||
# Not sure why this is failing. | ||
- toolchain: nightly | ||
platform: { os_name: linux-arm64 } | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Cache | ||
uses: Swatinem/rust-cache@v2 | ||
- name: Install musl-tools on Linux | ||
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools | ||
if: contains(matrix.platform.name, 'musl') | ||
- name: Build Binary | ||
uses: houseabsolute/actions-rust-cross@v0 | ||
with: | ||
command: "build" | ||
target: ${{ matrix.platform.target }} | ||
toolchain: ${{ matrix.toolchain }} | ||
args: "--locked --release" | ||
strip: true | ||
- name: Run Tests | ||
uses: houseabsolute/actions-rust-cross@v0 | ||
with: | ||
command: "test" | ||
target: ${{ matrix.platform.target }} | ||
toolchain: ${{ matrix.toolchain }} | ||
args: "--locked --release" | ||
if: ${{ !matrix.platform.skip_tests }} | ||
- name: Get the Version | ||
if: env.VERSION == '' | ||
run: echo "VERSION=$(grep "^version" Cargo.toml | sed -r 's/version[^"]+"([^"]+).*/\1/')" >> $GITHUB_ENV | ||
- name: Determine Archive Name | ||
shell: bash | ||
run: | | ||
echo "ARCHIVE=pgxn_meta-v$VERSION-${{ matrix.platform.os_name }}" >> $GITHUB_ENV | ||
- name: Package Archive | ||
shell: bash | ||
run: | | ||
printf "Packaging %s\n" "$ARCHIVE" | ||
mkdir "$ARCHIVE" | ||
cp "target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}" "$ARCHIVE"/ | ||
cp {README.md,CHANGELOG.md,LICENSE.md} "$ARCHIVE"/ | ||
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then | ||
7z a "$ARCHIVE.zip" "$ARCHIVE" | ||
else | ||
tar czvf "$ARCHIVE.tar.gz" "$ARCHIVE" | ||
fi | ||
if: | | ||
matrix.toolchain == 'stable' && | ||
( startsWith( github.ref, 'refs/tags/v' ) || | ||
github.ref == 'refs/tags/test-release' ) | ||
- name: Publish Artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
path: "pgxn_meta-*" | ||
if: matrix.toolchain == 'stable' && github.ref == 'refs/tags/test-release' | ||
- name: Check the Version | ||
shell: bash | ||
run: | | ||
if [ "${{ github.ref_name }}" != "v$VERSION" ]; then | ||
printf "Cargo.toml version %s does not match tag %s\n" "$VERSION" "${{ github.ref_name }}" >&2 | ||
exit 1 | ||
fi | ||
if: matrix.toolchain == 'stable' && startsWith( github.ref, 'refs/tags/v' ) | ||
- name: Publish GitHub Release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
draft: true | ||
files: "pgxn_meta*" | ||
body_path: CHANGELOG.md | ||
if: matrix.toolchain == 'stable' && startsWith( github.ref, 'refs/tags/v' ) |
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,29 @@ | ||
name: 📦 Cargo Publish | ||
on: | ||
push: | ||
branches-ignore: [wip/**] | ||
tags: ["**"] | ||
pull_request: | ||
jobs: | ||
test: | ||
name: 📦 Cargo ${{ startsWith(github.ref, 'refs/tags') && 'Publish' || 'Package' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Rust Cache | ||
uses: Swatinem/rust-cache@v2 | ||
- name: Setup Rust | ||
uses: dtolnay/rust-toolchain@stable | ||
with: { toolchain: stable } | ||
- name: Package | ||
run: cargo publish --dry-run | ||
- name: Publish | ||
run: | | ||
v="v$(grep "^version" Cargo.toml | sed -r 's/version[^"]+"([^"]+).*/\1/')" | ||
if [ "$v" != "$GITHUB_REF_NAME" ]; then | ||
printf "Cargo.toml version %s does not match tag %s\n" "$v" "$GITHUB_REF_NAME" >&2 | ||
exit 1 | ||
fi | ||
cargo publish | ||
if: startsWith( github.ref, 'refs/tags/v' ) |
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
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,39 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. It uses the | ||
[Keep a Changelog] format, and this project adheres to [Semantic Versioning]. | ||
|
||
[Keep a Changelog]: https://keepachangelog.com/en/1.1.0/ | ||
[Semantic Versioning]: https://semver.org/spec/v2.0.0.html | ||
"Semantic Versioning 2.0.0" | ||
|
||
## [v0.1.0] — 2024-08-07 | ||
|
||
The theme of this release is *Cross Compilation.* | ||
|
||
### ⚡ Improvements | ||
|
||
* First release, everything is new! | ||
* JSON Schema for PGXN Meta Spec v1 and v2 | ||
* JSON Schema validation using [boon] | ||
* Comprehensive Testing | ||
* `pgxn_meta` binary and crate | ||
|
||
### 🏗️ Build Setup | ||
|
||
* Built with Rust | ||
* Use [cross] and [actions-rust-cross] to cross-compile and release binaries | ||
for multiple OSes | ||
* Install from [crates.io] or [GitHub] | ||
|
||
### 📚 Documentation | ||
|
||
* Build and install docs in the [README] | ||
|
||
[v0.1.0]: https://github.com/pgxn/meta/compare/4c207a6...v0.1.0 | ||
[boon]: https://github.com/santhosh-tekuri/boon | ||
[cross]: https://github.com/cross-rs/cross | ||
[actions-rust-cross]: https://github.com/houseabsolute/actions-rust-cross | ||
[crates.io]: https://crates.io/crates/pgxn_meta | ||
[GitHub]: https://github.com/pgxn/meta/releases | ||
[README]: https://github.com/pgxn/meta/blob/v0.1.0/README.md |
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
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 @@ | ||
[build.env] | ||
passthrough = ["GITHUB_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