diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml deleted file mode 100644 index 6580341f..00000000 --- a/.github/workflows/publish-release.yml +++ /dev/null @@ -1,70 +0,0 @@ -# Publishes a release to npm/crates.io -# -# To trigger this: -# -# - go to Actions > PublishRelease -# - click the Run Workflow dropdown in the top-right -# - enter the tag of the release as “Release Tag” (e.g. v0.3.18) -name: PublishRelease - -on: - workflow_dispatch: - inputs: - tag: - description: 'Release Tag' - required: true - type: string - -jobs: - # This is a bit convoluted so that the other parts of this workflow remain - # the same even if the way the tag is defined is more complicated - download-tag: - runs-on: ubuntu-latest - outputs: - tag: ${{ steps.print-tag.outputs.tag }} - steps: - - id: print-tag - run: echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT" - - # Publish the npm package we uploaded to the github release - npm-publish: - runs-on: ubuntu-latest - needs: download-tag - permissions: - contents: read - id-token: write - steps: - - name: Checkout sources - uses: actions/checkout@v3 - with: - ref: ${{needs.download-tag.outputs.tag}} - fetch-depth: 0 - - uses: actions/setup-node@v3 - with: - node-version: '18.x' - registry-url: 'https://registry.npmjs.org' - - run: npm install -g npm - - run: npm publish --access public https://github.com/axodotdev/oranda/releases/download/${{needs.download-tag.outputs.tag}}/oranda-npm-package.tar.gz - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - # publish the current repo state to crates.io - cargo-publish: - runs-on: ubuntu-latest - needs: download-tag - steps: - - name: Checkout sources - uses: actions/checkout@v3 - with: - ref: ${{needs.download-tag.outputs.tag}} - fetch-depth: 0 - - name: Install stable toolchain - uses: dtolnay/rust-toolchain@master - with: - toolchain: stable - - run: cargo publish -p oranda-generate-css --token ${CRATES_TOKEN} - env: - CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }} - - run: cargo publish -p oranda --token ${CRATES_TOKEN} - env: - CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 14ac2efe..c9c32af2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -# Copyright 2022-2023, axodotdev +# Copyright 2022-2024, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # # CI that: @@ -7,9 +7,9 @@ # * builds artifacts with cargo-dist (archives, installers, hashes) # * uploads those artifacts to temporary workflow zip # * on success, uploads the artifacts to Axo Releases and makes an Announcement -# * on success, uploads the artifacts to a Github Release +# * on success, uploads the artifacts to a GitHub Release # -# Note that the Github Release will be created with a generated +# Note that the GitHub Release will be created with a generated # title/body based on your changelogs. name: Release @@ -32,7 +32,7 @@ permissions: # packages versioned/released in lockstep). # # If you push multiple tags at once, separate instances of this workflow will -# spin up, creating an independent announcement for each one. However Github +# spin up, creating an independent announcement for each one. However, GitHub # will hard limit this to 3 tags per commit, as it will assume more tags is a # mistake. # @@ -64,7 +64,7 @@ jobs: # 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.2/cargo-dist-installer.sh | sh" + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.14.0-prerelease.6/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. @@ -107,10 +107,15 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json steps: + - name: enable windows longpaths + run: | + git config --global core.longpaths true - uses: actions/checkout@v4 with: submodules: recursive - uses: swatinem/rust-cache@v2 + with: + key: ${{ join(matrix.targets, '-') }} - name: Install cargo-dist run: ${{ matrix.install_dist }} # Get the dist-manifest @@ -137,7 +142,7 @@ jobs: run: | # Parse out what we just built and upload it to scratch storage echo "paths<> "$GITHUB_OUTPUT" - jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT" + jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT" echo "EOF" >> "$GITHUB_OUTPUT" cp dist-manifest.json "$BUILD_MANIFEST_NAME" @@ -164,7 +169,7 @@ jobs: submodules: recursive - name: Install cargo-dist shell: bash - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.11.0-prerelease.2/cargo-dist-installer.sh | sh" + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.14.0-prerelease.6/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@v4 @@ -180,7 +185,7 @@ jobs: # Parse out what we just built and upload it to scratch storage echo "paths<> "$GITHUB_OUTPUT" - jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT" + jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT" echo "EOF" >> "$GITHUB_OUTPUT" cp dist-manifest.json "$BUILD_MANIFEST_NAME" @@ -219,7 +224,7 @@ jobs: with: submodules: recursive - name: Install cargo-dist - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.11.0-prerelease.2/cargo-dist-installer.sh | sh" + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.14.0-prerelease.6/cargo-dist-installer.sh | sh" # Fetch artifacts from scratch-storage - name: Fetch artifacts uses: actions/download-artifact@v4 @@ -228,7 +233,7 @@ jobs: path: target/distrib/ merge-multiple: true # Upload files to Axo Releases and create the Releases - # This is a harmless no-op for Github Releases, hosting for that happens in "announce" + # This is a harmless no-op for GitHub Releases, hosting for that happens in "announce" - id: host shell: bash run: | @@ -260,37 +265,84 @@ jobs: repository: "axodotdev/homebrew-tap" token: ${{ secrets.HOMEBREW_TAP_TOKEN }} # So we have access to the formula - - name: Fetch local artifacts + - name: Fetch homebrew formulae uses: actions/download-artifact@v4 with: pattern: artifacts-* path: Formula/ merge-multiple: true + # This is extra complex because you can make your Formula name not match your app name + # so we need to find releases with a *.rb file, and publish with that filename. - name: Commit formula files run: | git config --global user.name "${GITHUB_USER}" git config --global user.email "${GITHUB_EMAIL}" - for release in $(echo "$PLAN" | jq --compact-output '.releases[]'); do - name=$(echo "$release" | jq .app_name --raw-output) + for release in $(echo "$PLAN" | jq --compact-output '.releases[] | select([.artifacts[] | endswith(".rb")] | any)'); do + filename=$(echo "$release" | jq '.artifacts[] | select(endswith(".rb"))' --raw-output) + name=$(echo "$filename" | sed "s/\.rb$//") version=$(echo "$release" | jq .app_version --raw-output) - git add Formula/${name}.rb + git add "Formula/${filename}" git commit -m "${name} ${version}" done git push + publish-npm: + needs: + - plan + - host + runs-on: "ubuntu-20.04" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PLAN: ${{ needs.plan.outputs.val }} + if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }} + steps: + - name: Fetch npm packages + uses: actions/download-artifact@v4 + with: + pattern: artifacts-* + path: npm/ + merge-multiple: true + - uses: actions/setup-node@v4 + with: + node-version: '20.x' + registry-url: 'https://registry.npmjs.org' + - run: | + for release in $(echo "$PLAN" | jq --compact-output '.releases[] | select([.artifacts[] | endswith("-npm-package.tar.gz")] | any)'); do + pkg=$(echo "$release" | jq '.artifacts[] | select(endswith("-npm-package.tar.gz"))' --raw-output) + npm publish --access public "./npm/${pkg}" + done + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + custom-publish-crates: + needs: + - plan + - host + if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }} + uses: ./.github/workflows/publish-crates.yml + with: + plan: ${{ needs.plan.outputs.val }} + secrets: inherit + # publish jobs get escalated permissions + permissions: + id-token: write + packages: write + # Create an Announcement for all the Axo Releases, updating the "latest" release - # Create a Github Release while uploading all files to it + # Create a GitHub Release while uploading all files to it announce: needs: - plan - host - publish-homebrew-formula + - publish-npm + - custom-publish-crates # use "always() && ..." to allow us to wait for all publish jobs while # still allowing individual publish jobs to skip themselves (for prereleases). # "host" however must run to completion, no skipping allowed! - if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') }} + if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') && (needs.publish-npm.result == 'skipped' || needs.publish-npm.result == 'success') && (needs.custom-publish-crates.result == 'skipped' || needs.custom-publish-crates.result == 'success') }} runs-on: "ubuntu-20.04" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -300,7 +352,7 @@ jobs: with: submodules: recursive - name: Install cargo-dist - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.11.0-prerelease.2/cargo-dist-installer.sh | sh" + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.14.0-prerelease.6/cargo-dist-installer.sh | sh" - name: Fetch Axo Artifacts uses: actions/download-artifact@v4 with: @@ -310,7 +362,7 @@ jobs: - name: Announce Axo Releases run: | cargo dist host --steps=announce ${{ needs.plan.outputs.tag-flag }} - - name: "Download Github Artifacts" + - name: "Download GitHub Artifacts" uses: actions/download-artifact@v4 with: pattern: artifacts-* @@ -320,7 +372,7 @@ jobs: run: | # Remove the granular manifests rm -f artifacts/*-dist-manifest.json - - name: Create Github Release + - name: Create GitHub Release uses: ncipollo/release-action@v1 with: tag: ${{ needs.plan.outputs.tag }} diff --git a/.github/workflows/standalone-oranda-css.yml b/.github/workflows/standalone-oranda-css.yml deleted file mode 100644 index 79c67ba7..00000000 --- a/.github/workflows/standalone-oranda-css.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Release - CSS (standalone) - -permissions: - contents: write - -on: - push: - tags: - - 'css-?v[0-9]+*' - -jobs: - # Create the Github Release™ so the packages have something to be uploaded to - create-release: - runs-on: ubuntu-latest - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v3 - - id: create-release - run: | - # Create the Github Release™ - gh release create ${{ github.ref_name }} --draft - echo "created announcement!" - build-css: - needs: [create-release] - runs-on: ubuntu-latest - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 - - id: build-css - run: | - cd oranda-css - yarn install - # Run tailwind build - yarn run build - ls dist - echo "built css!" - # Upload css to the Github Release™ - gh release upload ${{ github.ref_name }} dist/oranda.css - echo "uploaded css!" - publish-release: - runs-on: ubuntu-latest - needs: [build-css] - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v3 - - name: mark release as non-draft - run: | - gh release edit ${{ github.ref_name }} --draft=false diff --git a/Cargo.toml b/Cargo.toml index 0f9badcc..0894d0a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,17 +87,17 @@ 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.11.0-prerelease.2" +cargo-dist-version = "0.14.0-prerelease.6" # CI backends to support -ci = ["github"] +ci = "github" # The installers to generate for each app installers = ["shell", "powershell", "npm", "homebrew"] # A GitHub repo to push Homebrew formulas to tap = "axodotdev/homebrew-tap" # Publish jobs to run in CI -publish-jobs = ["homebrew"] +publish-jobs = ["homebrew", "npm", "./publish-crates"] # Target platforms to build apps for (Rust target-triple syntax) -targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"] +targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "aarch64-unknown-linux-musl", "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) @@ -110,6 +110,8 @@ features = ["build-with-tailwind"] pr-run-mode = "plan" # Where to host releases hosting = ["axodotdev", "github"] +# Whether to install an updater program +install-updater = false [[workspace.metadata.dist.extra-artifacts]] artifacts = ["oranda-config-schema.json"] @@ -118,3 +120,7 @@ build = ["cargo", "run", "--", "config-schema", "--output=oranda-config-schema.j [[workspace.metadata.dist.extra-artifacts]] artifacts = ["oranda.css"] build = ["cargo", "run", "--", "generate-css", "--out-dir=./"] + +[workspace.metadata.dist.github-custom-runners] +aarch64-unknown-linux-gnu = "buildjet-8vcpu-ubuntu-2204-arm" +aarch64-unknown-linux-musl = "buildjet-8vcpu-ubuntu-2204-arm"