Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use extra artifacts instead of append release #667

Merged
merged 4 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 0 additions & 87 deletions .github/workflows/additional-release-assets.yml

This file was deleted.

65 changes: 38 additions & 27 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,33 @@ jobs:
with:
submodules: recursive
- name: Install cargo-dist
run: "curl --proto '=https' --tlsv1.2 -LsSf https:/axodotdev/cargo-dist/releases/download/v0.5.0/cargo-dist-installer.sh | sh"
# we specify bash to get pipefail; it guards against the `curl` command
# failing. otherwise `sh` won't catch that `curl` returned non-0
shell: bash
run: "curl --proto '=https' --tlsv1.2 -LsSf https:/axodotdev/cargo-dist/releases/download/v0.11.0-prerelease.1/cargo-dist-installer.sh | sh"
# sure would be cool if github gave us proper conditionals...
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
# functionality based on whether this is a pull_request, and whether it's from a fork.
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
# but also really annoying to build CI around when it needs secrets to work right.)
- id: plan
run: |
cargo dist ${{ !github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name) || (github.event.pull_request.head.repo.fork && 'plan' || 'host --steps=check') }} --output-format=json > dist-manifest.json
cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
echo "cargo dist ran successfully"
cat dist-manifest.json
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
cat plan-dist-manifest.json
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
- name: "Upload dist-manifest.json"
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: artifacts
path: dist-manifest.json
name: artifacts-plan-dist-manifest
path: plan-dist-manifest.json

# Build and packages all the platform-specific things
build-local-artifacts:
name: build-local-artifacts (${{ join(matrix.targets, ', ') }})
# Let the initial task tell us to not run (currently very blunt)
needs: plan
needs:
- plan
if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -109,10 +113,11 @@ jobs:
run: ${{ matrix.install_dist }}
# Get the dist-manifest
- name: Fetch local artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: artifacts
pattern: artifacts-*
path: target/distrib/
merge-multiple: true
- name: Install dependencies
run: |
${{ matrix.packages_install }}
Expand All @@ -135,9 +140,9 @@ jobs:

cp dist-manifest.json "$BUILD_MANIFEST_NAME"
- name: "Upload artifacts"
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: artifacts
name: artifacts-build-local-${{ join(matrix.targets, '_') }}
path: |
${{ steps.cargo-dist.outputs.paths }}
${{ env.BUILD_MANIFEST_NAME }}
Expand All @@ -150,19 +155,21 @@ jobs:
runs-on: "ubuntu-20.04"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_MANIFEST_NAME: target/distrib/dist-manifest.json
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install cargo-dist
run: "curl --proto '=https' --tlsv1.2 -LsSf https:/axodotdev/cargo-dist/releases/download/v0.5.0/cargo-dist-installer.sh | sh"
shell: bash
run: "curl --proto '=https' --tlsv1.2 -LsSf https:/axodotdev/cargo-dist/releases/download/v0.11.0-prerelease.1/cargo-dist-installer.sh | sh"
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
- name: Fetch local artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: artifacts
pattern: artifacts-*
path: target/distrib/
merge-multiple: true
- id: cargo-dist
shell: bash
run: |
Expand All @@ -176,9 +183,9 @@ jobs:

cp dist-manifest.json "$BUILD_MANIFEST_NAME"
- name: "Upload artifacts"
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: artifacts
name: artifacts-build-global
path: |
${{ steps.cargo-dist.outputs.paths }}
${{ env.BUILD_MANIFEST_NAME }}
Expand All @@ -200,13 +207,14 @@ jobs:
with:
submodules: recursive
- name: Install cargo-dist
run: "curl --proto '=https' --tlsv1.2 -LsSf https:/axodotdev/cargo-dist/releases/download/v0.5.0/cargo-dist-installer.sh | sh"
run: "curl --proto '=https' --tlsv1.2 -LsSf https:/axodotdev/cargo-dist/releases/download/v0.11.0-prerelease.1/cargo-dist-installer.sh | sh"
# Fetch artifacts from scratch-storage
- name: Fetch artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: artifacts
pattern: artifacts-*
path: target/distrib/
merge-multiple: true
# This is a harmless no-op for Github Releases, hosting for that happens in "announce"
- id: host
shell: bash
Expand All @@ -216,9 +224,10 @@ jobs:
cat dist-manifest.json
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
- name: "Upload dist-manifest.json"
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: artifacts
# Overwrite the previous copy
name: artifacts-dist-manifest
path: dist-manifest.json

publish-homebrew-formula:
Expand All @@ -239,10 +248,11 @@ jobs:
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
# So we have access to the formula
- name: Fetch local artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: artifacts
pattern: artifacts-*
path: Formula/
merge-multiple: true
- name: Commit formula files
run: |
git config --global user.name "${GITHUB_USER}"
Expand Down Expand Up @@ -275,10 +285,11 @@ jobs:
with:
submodules: recursive
- name: "Download Github Artifacts"
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: artifacts
pattern: artifacts-*
path: artifacts
merge-multiple: true
- name: Cleanup
run: |
# Remove the granular manifests
Expand Down
12 changes: 10 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ lto = "thin"
# Config for 'cargo dist'
[workspace.metadata.dist]
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
cargo-dist-version = "0.5.0"
cargo-dist-version = "0.11.0-prerelease.1"
# CI backends to support
ci = ["github"]
# The installers to generate for each app
Expand All @@ -97,7 +97,7 @@ tap = "axodotdev/homebrew-tap"
# Publish jobs to run in CI
publish-jobs = ["homebrew"]
# Target platforms to build apps for (Rust target-triple syntax)
targets = ["x86_64-unknown-linux-gnu", "aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]
# The archive format to use for windows builds (defaults .zip)
windows-archive = ".tar.gz"
# The archive format to use for non-windows builds (defaults .tar.xz)
Expand All @@ -108,3 +108,11 @@ npm-scope = "@axodotdev"
features = ["build-with-tailwind"]
# Publish jobs to run in CI
pr-run-mode = "plan"

[[workspace.metadata.dist.extra-artifacts]]
artifacts = ["oranda-config-schema.json"]
build = ["cargo", "run", "--", "config-schema", "--output=oranda-config-schema.json"]

[[workspace.metadata.dist.extra-artifacts]]
artifacts = ["oranda.css"]
build = ["cargo", "run", "--", "generate-css", "--out-dir=./"]
26 changes: 21 additions & 5 deletions src/commands/print.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,44 @@
use axoasset::LocalAsset;
use camino::Utf8PathBuf;
use clap::Parser;
use oranda::errors::*;
use oranda_generate_css::default_css_output_dir;

#[derive(Debug, Parser)]
pub struct ConfigSchema {}
pub struct ConfigSchema {
/// Write the config schema to the named file instead of stdout
#[clap(long)]
pub output: Option<String>,
}

impl ConfigSchema {
pub fn run(&self) -> Result<()> {
let schema = schemars::schema_for!(oranda::config::OrandaLayer);
let json_schema =
serde_json::to_string_pretty(&schema).expect("failed to stringify schema!?");
println!("{json_schema}");

if let Some(output) = &self.output {
let contents = json_schema + "\n";
LocalAsset::write_new(&contents, output)?;
} else {
println!("{json_schema}");
}
Ok(())
}
}

#[derive(Debug, Parser)]
pub struct GenerateCss {}
pub struct GenerateCss {
#[clap(long)]
out_dir: Option<Utf8PathBuf>,
}

impl GenerateCss {
pub fn run(&self) -> Result<()> {
let out_dir = default_css_output_dir();
let out_dir = self.out_dir.clone().unwrap_or_else(default_css_output_dir);
let out_file = out_dir.join("oranda.css");
oranda_generate_css::build_css(&out_dir)?;
tracing::info!("CSS placed in {out_dir}/oranda.css");
tracing::info!("CSS placed in {out_file}");
Ok(())
}
}
Loading