diff --git a/.github/workflows/additional-release-assets.yml b/.github/workflows/additional-release-assets.yml deleted file mode 100644 index 7176a240..00000000 --- a/.github/workflows/additional-release-assets.yml +++ /dev/null @@ -1,87 +0,0 @@ -# After a release is successfully published, upload extra assets to it -name: AppendRelease - -# We're going to edit a gh release, so we need that permission -permissions: - contents: write - -on: - # Whenever a workflow called "Release" completes, run this! - workflow_run: - workflows: ["Release"] - types: - - completed - -jobs: - # Check if we should actually run by looking for the host job - should-run: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} - outputs: - val: ${{ steps.check.outputs.result }} - steps: - - id: check - uses: actions/github-script@v6 - with: - result-encoding: string - script: | - let allRuns = await github.rest.actions.listJobsForWorkflowRun({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.payload.workflow_run.id, - }); - for (const job of allRuns.data.jobs) { - if (job.name == "host") { - if (job.status == "completed" && job.conclusion == "success") { - return "run" - } - } - } - return "skip" - - # Generate oranda-config-schema.json and upload it to the release - schema: - name: Add schema to release - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - runs-on: ubuntu-latest - needs: ["should-run"] - if: ${{ needs.should-run.outputs.val == 'run' }} - steps: - # Setup - - uses: actions/checkout@v3 - with: - ref: ${{ github.event.workflow_run.head_branch }} - fetch-depth: 0 - # We get the tag of the release in github.event.workflow_run.head_branch - # No idea why it's stored there with that name, but, it is? - - name: Install oranda and upload schema - run: | - echo "uploading schema to ${{ github.event.workflow_run.head_branch }}" - curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/oranda/releases/download/${{ github.event.workflow_run.head_branch }}/oranda-installer.sh | sh - oranda config-schema > oranda-config-schema.json - gh release upload ${{ github.event.workflow_run.head_branch }} oranda-config-schema.json - - # Generate oranda.css and upload it to the release - oranda-css: - name: Add oranda-css to release - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - runs-on: ubuntu-latest - needs: ["should-run"] - if: ${{ needs.should-run.outputs.val == 'run' }} - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.event.workflow_run.head_branch }} - fetch-depth: 0 - - name: Install oranda and build CSS - run: | - echo "uploading CSS to ${{ github.event.workflow_run.head_branch }}" - curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/oranda/releases/download/${{ github.event.workflow_run.head_branch }}/oranda-installer.sh | sh - oranda generate-css - ls oranda-css/dist - echo "built css!" - # Upload css to the Github Releaseā„¢ - gh release upload ${{ github.event.workflow_run.head_branch }} oranda-css/dist/oranda.css - echo "uploaded css!" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3c54cd6e..3e58d447 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,7 +59,10 @@ jobs: with: submodules: recursive - name: Install cargo-dist - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/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://github.com/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. @@ -67,21 +70,22 @@ jobs: # 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 @@ -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 }} @@ -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 }} @@ -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://github.com/axodotdev/cargo-dist/releases/download/v0.5.0/cargo-dist-installer.sh | sh" + shell: bash + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/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: | @@ -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 }} @@ -200,13 +207,14 @@ jobs: with: submodules: recursive - name: Install cargo-dist - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.5.0/cargo-dist-installer.sh | sh" + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/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 @@ -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: @@ -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}" @@ -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 diff --git a/Cargo.toml b/Cargo.toml index 1b0ce4ee..2f045a35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 @@ -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) @@ -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=./"] diff --git a/src/commands/print.rs b/src/commands/print.rs index d723bfd9..5f05aed7 100644 --- a/src/commands/print.rs +++ b/src/commands/print.rs @@ -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, +} 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, +} 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(()) } }