Skip to content

Commit

Permalink
chore: release docs and cp readmes (#530)
Browse files Browse the repository at this point in the history
Closes out #346 with release updates. 

Includes:

- [x] Add build step for homestar-runtime npm wrapper (cc @hugomrdias).
- [X] Makes nix build of homestar part of `push` event on `main` branch.
- [X] Local build optimization(s) with
[cargo-hakari](https://crates.io/crates/cargo-hakari).
- [X] Graceful test drop, specified for unix/windows
- [X] Local windows-cross target
- [X] Fix GH links for releases on crates.io.

---------

Signed-off-by: Zeeshan Lakhani <[email protected]>
Co-authored-by: Brian Ginsburg <[email protected]>
Co-authored-by: Hugo Dias <[email protected]>
  • Loading branch information
3 people authored Jan 25, 2024
1 parent 0d778d3 commit 4deac65
Show file tree
Hide file tree
Showing 39 changed files with 852 additions and 405 deletions.
30 changes: 30 additions & 0 deletions .config/hakari.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file contains settings for `cargo hakari`.
# See https://docs.rs/cargo-hakari/latest/cargo_hakari/config for a full list of options.

hakari-package = "homestar-workspace-hack"

# Format version for hakari's output. Version 4 requires cargo-hakari 0.9.22 or above.
dep-format-version = "4"

workspace-hack-line-style = "workspace-dotted"

# Setting workspace.resolver = "2" in the root Cargo.toml is HIGHLY recommended.
# Hakari works much better with the new feature resolver.
# For more about the new feature resolver, see:
# https://blog.rust-lang.org/2021/03/25/Rust-1.51.0.html#cargos-new-feature-resolver
resolver = "2"

# Add triples corresponding to platforms commonly used by developers here.
# https://doc.rust-lang.org/rustc/platform-support.html
platforms = [
"wasm32-unknown-unknown",
"wasm32-wasi",
"x86_64-apple-darwin",
"aarch64-apple-darwin",
"x86_64-unknown-linux-gnu",
"x86_64-unknown-linux-musl",
"aarch64-unknown-linux-musl",
]

# Write out exact versions rather than a semver range. (Defaults to false.)
# exact-versions = true
6 changes: 4 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

*

!**/Cargo.toml
Expand All @@ -10,5 +11,6 @@
!diesel.toml
!**/wit

homestar-functions/src
homestar-functions/**/wit
examples
homestar-functions
homestar-workspace-hack
65 changes: 53 additions & 12 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
binary-builds:
if: >
startsWith(github.event.release.name, 'homestar-runtime') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.force-publish)
(github.event_name == 'workflow_dispatch' && github.event.inputs.force-builds)
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
include: LICENSE,README.md
token: ${{ secrets.GITHUB_TOKEN }}

npm-publish:
npm-publish-arch:
needs: binary-builds
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
with:
node-version: lts/*
registry-url: "https://registry.npmjs.org"
- name: Install cargo get
- name: Install cargo-get
run: cargo install cargo-get
- name: Prepare os/arch packages
shell: bash
Expand All @@ -146,29 +146,66 @@ jobs:
echo "node_pkg=${node_pkg}" >> "$GITHUB_ENV"
cd homestar-runtime/npm
mkdir -p "${node_pkg}/bin"
envsubst < package.json.tmpl > "${node_pkg}/package.json"
envsubst < package-json-arch.tmpl > "${node_pkg}/package.json"
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: ${{ matrix.target }}
path: "homestar-runtime/npm/${{ env.node_pkg }}/bin"
- name: Publish production
- name: Publish arch packages to production
if: github.event_name == 'release' && github.event.action == 'published'
run: |
cp homestar-runtime/README.md "homestar-runtime/npm/${{ env.node_pkg }}"
cd "homestar-runtime/npm/${{ env.node_pkg }}"
chmod +x bin/${{ matrix.bin }}
npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Publish RC
- name: Publish arch packages RC
if: github.event_name == 'workflow_dispatch'
run: |
cp homestar-runtime/README.md "homestar-runtime/npm/${{ env.node_pkg }}"
cd "homestar-runtime/npm/${{ env.node_pkg }}"
chmod +x bin/${{ matrix.bin }}
npm version $(cargo get package.version)-rc.$(date +%s) --git-tag-version false
npm publish --access public --tag rc
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

npm-publish-main:
needs: npm-publish-arch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
registry-url: "https://registry.npmjs.org"
- name: Install cargo get
run: cargo install cargo-get
- name: Publish main package to production
if: github.event_name == 'release' && github.event.action == 'published'
run: |
export node_version=$(cargo get workspace.package.version)
cp homestar-runtime/README.md homestar-runtime/npm/base
cd homestar-runtime/npm
envsubst < package-json-base.tmpl > "base/package.json"
cd base
npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Publish main package RC
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.force-builds)
run: |
export node_version="$(cargo get workspace.package.version)-rc.$(date +%s)"
cp homestar-runtime/README.md homestar-runtime/npm/base
cd homestar-runtime/npm
envsubst < package-json-baserc.tmpl > "base/package.json"
cd base
npm publish --access public --tag rc
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

build-packages:
needs: binary-builds
runs-on: ubuntu-latest
Expand Down Expand Up @@ -238,7 +275,7 @@ jobs:
docker-build:
if: >
startsWith(github.event.release.name, 'homestar-runtime') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.force-publish)
(github.event_name == 'workflow_dispatch' && github.event.inputs.force-builds)
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: "1"
Expand All @@ -265,10 +302,14 @@ jobs:
sudo apt-get clean
sudo rm -rf /usr/share/dotnet
- name: Get Current Version
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.force-publish)
- name: Install cargo-get
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.force-builds)
run: cargo install cargo-get

- name: Set Current Version
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.force-builds)
id: crate-version
run: echo version=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "homestar-runtime") | .version') >> $GITHUB_OUTPUT
run: echo version=$(cargo get workspace.package.version)-rc.$(date +%s) >> $GITHUB_OUTPUT

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand Down Expand Up @@ -296,7 +337,7 @@ jobs:
type=sha
- name: Metadata
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.force-publish)
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.force-builds)
id: meta-dispatch
uses: docker/metadata-action@v5
with:
Expand All @@ -320,7 +361,7 @@ jobs:
labels: ${{ steps.meta-release.outputs.labels }}

- name: Docker Build & Push
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.force-publish)
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.force-builds)
uses: docker/build-push-action@v5
with:
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ jobs:
needs: changes
if: ${{ needs.changes.outputs.nix == 'true' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -51,8 +49,11 @@ jobs:
ignore-missing-flake-lock: false
fail-mode: true

- name: Nix Build
- name: Nix Develop Check
run: |
nix develop --show-trace -c irust --version
nix develop --show-trace -c rustc --version
nix build . && ./result/bin/homestar --version
- name: Nix Homestar Build
if: ${{ github.event_name == 'push' }}
run: nix build . && ./result/bin/homestar --version
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ on:
description: Publish Releases at Anytime

workflow_run:
workflows: [ 🧪 Tests and Checks ]
workflows: [🧪 Tests and Checks]
branches: [main]
types: [ completed ]
types: [completed]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
35 changes: 21 additions & 14 deletions .github/workflows/tests_and_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: 🧪 Tests and Checks

on:
push:
branches: [ main ]
branches: [main]

pull_request:
branches: [ '**' ]
branches: ["**"]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -48,8 +48,8 @@ jobs:
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.examples == 'true' }}
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -90,12 +90,19 @@ jobs:
- name: Run Linter
run: cargo clippy --all -- -D warnings

# TODO: Return upon new version.
# - name: Verify Publishing of crates
# uses: katyo/publish-crates@v2
# if: ${{ matrix.rust-toolchain == 'stable' }}
# with:
# dry-run: true
- name: Install cargo-hakari
if: ${{ matrix.rust-toolchain == 'stable' }}
uses: taiki-e/install-action@v2
with:
tool: cargo-hakari

- name: Check workspace-hack Cargo.toml is up-to-date
if: ${{ matrix.rust-toolchain == 'stable' }}
run: cargo hakari generate --diff

- name: Check Crates Depend on workspace-hack
if: ${{ matrix.rust-toolchain == 'stable' }}
run: cargo hakari manage-deps --dry-run

# Only "test" release build on push event.
- name: Test Release
Expand Down Expand Up @@ -140,8 +147,8 @@ jobs:
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' }}
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -283,8 +290,8 @@ jobs:
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' }}
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
Expand Down
12 changes: 10 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,16 @@ repos:
args: ["--workspace", "--document-private-items"]
types: [rust]
pass_filenames: false
- id: cargo-hakari
name: workspace-hack
description: Ensure workspace-hack works correctly
entry: bash -c 'cargo hakari generate --diff && cargo hakari manage-deps --dry-run && cargo hakari verify'
language: rust
files: Cargo\.(toml|lock)
pass_filenames: false

- repo: https://github.com/kamadorueda/alejandra
rev: bb7f2ad3f176aa8e9e2944a10061f7989c8fef17 # frozen: 1.3.0
rev: bb7f2ad3f176aa8e9e2944a10061f7989c8fef17 # frozen: 1.3.0
hooks:
- id: alejandra
files: \.nix$
Expand All @@ -55,6 +62,7 @@ repos:
args: ["fmt"]
types:
- toml
exclude: homestar-workspace-hack/Cargo.toml

- repo: https://github.com/compilerla/conventional-pre-commit
rev: v2.1.1
Expand All @@ -75,7 +83,7 @@ repos:
- id: check-yaml
- id: check-json
- id: check-added-large-files
args: ['--maxkb=4000']
args: ["--maxkb=4000"]
- id: detect-private-key
exclude: __testkey
- id: check-executables-have-shebangs
Expand Down
4 changes: 2 additions & 2 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
In the interest of fostering an open, inclusive, and welcoming environment, all
members, contributors, and maintainers interacting within our online community
(including Discord, Discourse, etc.), on affiliated projects and repositories
(including issues, pull requests, and discussions on Github), and/or involved
(including issues, pull requests, and discussions on GitHub), and/or involved
with associated events pledge to accept and observe the following Code of
Conduct.

Expand Down Expand Up @@ -67,7 +67,7 @@ This Code of Conduct applies within all project and community spaces, as well as
in any public spaces where an individual representing the community is involved.
This covers

- Interactions on the Github repository, including discussions, issues, pull
- Interactions on the GitHub repository, including discussions, issues, pull
requests, commits, and wikis
- Interactions on any affiliated Discord, Slack, IRC, or related online
communities and forums like Discourse, etc.
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ need to be the best programmer to contribute. Our discord is open for questions
problems they may have encountered on similar issues.

3. **Fork** the repository
- A fork creates a copy of the code on your Github, so you can work on it
- A fork creates a copy of the code on your GitHub, so you can work on it
separately from everyone else.
- You can learn more about forking [here][forking].

Expand Down
Loading

0 comments on commit 4deac65

Please sign in to comment.