wip: clean up workflows

This commit is contained in:
Jonathan Kelley 2024-02-21 21:08:46 -08:00
parent 112b4f9afb
commit 319eb29ff4
No known key found for this signature in database
GPG key ID: 1FBB50F7EB0A08BE
5 changed files with 226 additions and 475 deletions

View file

@ -1,25 +0,0 @@
# Attempt to backport a merged pull request to the latest stable release
#
# If the backported PR is succesfully merged
# Any PR without the "breaking" label will be attempted to be backported to the latest stable release
name: Backport merged pull request
on:
pull_request_target:
types: [closed]
permissions:
contents: write # so it can comment
pull-requests: write # so it can create pull requests
jobs:
backport:
name: Backport pull request
runs-on: ubuntu-latest
# Don't run on closed unmerged pull requests
if: github.event.pull_request.merged
steps:
- uses: actions/checkout@v4
- name: Create backport pull requests
uses: korthout/backport-action@v2

View file

@ -1,4 +1,9 @@
# Whenever an open PR is updated, the workflow will be triggered
#
# This can get expensive, so we do a lot of caching and checks to prevent unnecessary runs
name: Rust CI
description: Run all the tests and checks for the project
on:
push:
@ -255,24 +260,3 @@ jobs:
- name: test
run: |
${{ env.RUST_CARGO_COMMAND }} ${{ matrix.platform.command }} ${{ matrix.platform.args }} --target ${{ matrix.platform.target }}
# Coverage is disabled until we can fix it
# coverage:
# name: Coverage
# runs-on: ubuntu-latest
# container:
# image: xd009642/tarpaulin:develop-nightly
# options: --security-opt seccomp=unconfined
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Generate code coverage
# run: |
# apt-get update &&\
# apt-get install build-essential &&\
# apt install libwebkit2gtk-4.0-dev libgtk-3-dev libayatana-appindicator3-dev -y &&\
# cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out Xml
# - name: Upload to codecov.io
# uses: codecov/codecov-action@v2
# with:
# fail_ci_if_error: false

65
.github/workflows/merge.yml vendored Normal file
View file

@ -0,0 +1,65 @@
# Runs whenever a PR is merged:
# - attempt to backports fixes
# - upload nightly docs
# - upload nightly CLI builds
# - upload nightly vscode extension
# - upload benchmarks
# - compute coverge
#
# Note that direct commits to master circumvent this workflow!
# - name: Deploy Nightly Docs.rs
# uses: JamesIves/github-pages-deploy-action@v4.5.0
# with:
# branch: gh-pages
# folder: target/doc
# target-folder: api-docs/nightly
# repository-name: dioxuslabs/docsite
# clean: false
# token: ${{ secrets.DEPLOY_KEY }}
# # Attempt to backport a merged pull request to the latest stable release
# #
# # If the backported PR is succesfully merged
# # Any PR without the "breaking" label will be attempted to be backported to the latest stable release
# name: Backport merged pull request
# on:
# pull_request_target:
# types: [closed]
# permissions:
# contents: write # so it can comment
# pull-requests: write # so it can create pull requests
# jobs:
# backport:
# name: Backport pull request
# runs-on: ubuntu-latest
# # Don't run on closed unmerged pull requests
# if: github.event.pull_request.merged
# steps:
# - uses: actions/checkout@v4
# - name: Create backport pull requests
# uses: korthout/backport-action@v2
# Coverage is disabled until we can fix it
# coverage:
# name: Coverage
# runs-on: ubuntu-latest
# container:
# image: xd009642/tarpaulin:develop-nightly
# options: --security-opt seccomp=unconfined
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Generate code coverage
# run: |
# apt-get update &&\
# apt-get install build-essential &&\
# apt install libwebkit2gtk-4.0-dev libgtk-3-dev libayatana-appindicator3-dev -y &&\
# cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out Xml
# - name: Upload to codecov.io
# uses: codecov/codecov-action@v2
# with:
# fail_ci_if_error: false

156
.github/workflows/publish.yml vendored Normal file
View file

@ -0,0 +1,156 @@
# Release workflow
#
# We parallelize builds, dump all the artifacts into a release, and then publish the release
# This guarantees everything is properly built and cached in case anything goes wrong
#
# The artifacts also need to get pushed to the various places
# - the CLI goes to the releases page for binstall
# - the extension goes to the marketplace
# - the docs go to the website
#
# We need to be aware of the channel we're releasing
# - prerelease is master
# - stable is whatever the latest stable release is (ie 0.4 or 0.5 or 0.6 etc)
#
# It's intended that this workflow is run manually, and only when we're ready to release
on:
workflow_dispatch:
inputs:
channel:
type: choice
description: "Branch to publish"
required: true
description: Choose the branch to publish. If the branch is main, it will publish a patch prerelease.
options:
- main
- v0.4.x
- v0.5.x
- v0.6.x
# todo: more stable releases as time goes on
env:
# make sure we have the right semver.
# main is always a prepatch until we hit 1.0, and then this script needs to be updated
# note that we need to promote the prepatch to a minor bump when we actually do a release
# this means the version in git will always be one minor bump ahead of the actual release - basically meaning once
# we release a version, it's fair game to merge breaking changes to main since all semver-compatible changes will be
# backported automatically
SEMVER: ${{ github.event.inputs.channel == 'main' && 'prepatch' || 'patch' }}
PRERELEASE_TAG: ${{ github.event.inputs.channel == 'main' && '-prerelease' || '' }}
jobs:
# First, run checks (clippy, tests, etc) and then publish the crates to crates.io
release-crates:
steps:
# Checkout the right branch, and the nightly stuff
- uses: actions/checkout@v4
ref: ${{ github.event.inputs.channel }}
- run: sudo apt-get update
- run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2024-02-01
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
- uses: ilammy/setup-nasm@v1
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@v1.3.1
with: # speed things up a bit
large-packages: false
docker-images: false
swap-storage: false
# Just make sure clippy is happy before doing anything else
# Don't publish versions with clippy errors!
- name: Clippy
run: cargo clippy --workspace --all --examples --tests --all-features --all-targets -- -D warnings
# Build the docs here too before publishing, to ensure they're up to date
- name: cargo doc
run: RUSTDOCFLAGS="--cfg docsrs" cargo doc --no-deps --workspace --all-features
- name: Publish to crates.io
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
cargo workspaces version -y ${{ env.SEMVER }} --no-git-commit
# todo: actually just publish!
# cargo workspaces publish -y ${{ github.event.inputs.semver }}
# this will be more useful when we publish the website with updated docs
# Build the docs.rs docs and publish them to the website under the right folder
# v0.4.x -> docs/0.4
# v0.5.x -> docs/0.5 etc
# main -> docs/nightly
# strip the v from the channel, and the .x from the end, and replace main with nightly
# - name: determine docs folder by channel
# id: determine_docs_folder
# run: echo "::set-output name=folder::$(echo ${{ github.event.inputs.channel }} | sed 's/v//g' | sed 's/\.x//g' | sed 's/main/nightly/g')"
# Build the CLI for all platforms, uploading the artifacts to our releases page
release-cli:
needs: release-crates
permissions:
contents: write
strategy:
matrix:
include:
- target: x86_64-pc-windows-msvc
os: windows-latest
- target: aaarch64-pc-windows-msvc
os: windows-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
runs-on: ${{ matrix.platform.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
ref: ${{ github.event.inputs.channel }}
- name: Install stable
uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.70.0"
targets: ${{ matrix.platform.target }}
- uses: ilammy/setup-nasm@v1
- name: Setup cache
uses: Swatinem/rust-cache@v2
with:
workspaces: packages/cli -> ../../target
- name: Free Disk Space
uses: jlumbroso/free-disk-space@v1.3.1
with: # speed things up a bit
large-packages: false
docker-images: false
swap-storage: false
# Todo: we want `cargo install dx` to actually just use a prebuilt binary instead of building it
- name: Build and upload CLI binaries
uses: taiki-e/upload-rust-binary-action@v1
with:
bin: dx
token: ${{ secrets.GITHUB_TOKEN }}
target: ${{ matrix.platform.target }}
archive: dx-${{ matrix.platform.target }}${{ env.PRERELEASE_TAG }}
checksum: sha256
manifest_path: packages/cli/Cargo.toml
# todo: these things
# Run benchmarks, which we'll use to display on the website
# release-benchmarks:
# Build the vscode extension, uploading the artifact to the marketplace
# release-extension:

View file

@ -1,429 +0,0 @@
# Release workflow
#
# We parallelize builds, dump all the artifacts into a release, and then publish the release
# This guarantees everything is properly built and cached in case anything goes wrong
#
# The artifacts also need to get pushed to the various places
# - the CLI goes to the releases page for binstall
# - the extension goes to the marketplace
# - the docs go to the website
#
# We need to be aware of the channel we're releasing
# - prerelease is master
# - stable is whatever the latest stable release is (ie 0.4 or 0.5 or 0.6 etc)
#
# In theory, we could trigger this workflow and set the channel accordingly
on:
workflow_dispatch:
inputs:
channel:
type: choice
description: "Branch to publish"
required: true
description: Choose the branch to publish. If the branch is main, it will publish a prerelease.
# add more options as we release more stable versions.
# todo: automate branch selection
options:
- v0.4.x
- v0.5.x
- main
jobs:
# Build the CLI for all platforms
build-cli:
permissions:
contents: write
runs-on: ${{ matrix.platform.os }}
strategy:
matrix:
platform:
- {
target: x86_64-pc-windows-msvc,
os: windows-latest,
toolchain: "1.70.0",
}
- {
target: x86_64-apple-darwin,
os: macos-latest,
toolchain: "1.70.0",
}
- {
target: x86_64-unknown-linux-gnu,
os: ubuntu-latest,
toolchain: "1.70.0",
}
steps:
- uses: actions/checkout@v4
ref: ${{ github.event.inputs.channel }}
- name: Install stable
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.platform.toolchain }}
targets: ${{ matrix.platform.target }}
- uses: ilammy/setup-nasm@v1
- name: Setup cache
uses: Swatinem/rust-cache@v2
# cache only the cli - mmmm not sure if this is needed
with:
workspaces: packages/cli -> ../../target
# Build the vscode extension
build-extension:
# Build the docs
build-docs:
# Run benchmarks, which we'll use to display on the website
build-benchmarks:
# And then do the releases, once everything is built
# This should involve no rust and just pull down the artifacts
release:
depends-on: [build-cli, build-extension, build-docs, build-benchmarks]
# Checkout the right branch
- uses: actions/checkout@v4
ref: ${{ github.event.inputs.channel }}
# Before anything else, we need to publish the crates
# todo: set the semver based on the channel
# - all semver is a minor bump,
# - if it's main, it's a prerelease, so use the prerelease flag
- name: Publish to crates.io
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
# cargo workspaces version -y ${{ github.event.inputs.semver }}
# cargo workspaces publish -y ${{ github.event.inputs.semver }}
# Todo: we want `cargo install dx` to actually just use a prebuilt binary
- name: Build and upload CLI binaries
uses: taiki-e/upload-rust-binary-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
target: ${{ matrix.platform.target }}
bin: dx
archive: dx-${{ matrix.platform.target }}
checksum: sha256
manifest_path: packages/cli/Cargo.toml
# build the docs, CLI, extension, and release
jobs:
build-deploy:
runs-on: ubuntu-latest
environment: docs
steps:
# install rust, etc, with caching, and do some checks
- uses: actions/checkout@v4
- run: sudo apt-get update
- run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
# save-if: ${{ github.ref == 'refs/heads/main' }} # always save the cache
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@v1.3.1
with: # speed things up a bit
large-packages: false
docker-images: false
swap-storage: false
# Just make sure clippy is happy before doing anything else
# Don't publish versions with clippy errors!
- name: Clippy
run: cargo clippy --workspace --all --examples --tests --all-features --all-targets -- -D warnings
# Build the CLI... todo: do this in a matrix using binstall
- name: Build CLI
run: cargo build --release --bin dx
- name: Build Extension
run: cargo build --release --bin dx-ext
- name: Bundle extension
working-directory: ./packages/extension
run: vsce package && mv *.vsix ../../dx-ext.vsix
# Docs first...
# NOTE: Delete when the previous one is enabled
# NOTE: Comment out when https://github.com/rust-lang/mdBook/pull/1306 is merged and released
# - name: Setup mdBook
# uses: peaceiris/actions-mdbook@v1
# with:
# mdbook-version: "0.4.10"
- name: Setup mdBook
run: |
cargo install mdbook --git https://github.com/Demonthos/mdBook.git --branch master
- name: Build
run: cd docs &&
cd guide && mdbook build -d ../nightly/guide && cd .. &&
cd router && mdbook build -d ../nightly/router && cd ..
- name: Deploy docs 🚀
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
branch: gh-pages # The branch the action should deploy to.
folder: docs/nightly # The folder the action should deploy.
target-folder: docs
repository-name: dioxuslabs/docsite
# Don't clean the existing files, so the old docs are still available.
# todo: the history on the dociste is getting massive, so we should actually just be amending the commit
clean: false
token: ${{ secrets.DEPLOY_KEY }}
# Then the CLI
# Then the extension
# Then the release itself
# Release a number of things
# - the extension
# - the CLI
# - nightly docs
# - the website
# - crates themselves
# name: Publish to crates.io
# on:
# workflow_dispatch:
# inputs:
# semver:
# type: choice
# description: "Semver version to publish"
# required: true
# options:
# - patch
# - minor
# - major
# jobs:
# publish:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Set up Rust
# uses: actions-rs/toolchain@v1
# with:
# toolchain: nightly
# override: true
# - name: Install cargo-workspaces
# run: cargo install cargo-workspaces
# - name: Login to crates.io
# uses: actions-rs/cargo@v1
# with:
# toolchain: nightly
# command: login
# args: ${{ secrets.CRATES_TOKEN }}
# - name: Publish to crates.io
# run: |
# git config --global user.email "github-actions[bot]@users.noreply.github.com"
# git config --global user.name "github-actions[bot]"
# # Release as-is
# # This assumes the version tracking PR has been merged
# # cargo workspaces changed
# # # version will automatically commit back to the repo
# # # cargo workspaces version -y ${{ github.event.inputs.semver }}
# Whenever commits are merged to main, update or create a PR that bumps the version
# Tracks if changes are semver compatible
#
# We want to have a standing "major" update PR and a standing "minor" update PR where fixes are backported
#
# Whenever a PR is merged, we want to attempt to update the major/minor bump PRs
# - for main, it's as simple as running cargo workspaces version -y minor and dumping it into a PR
# - for backport, it's a bit more complicated, since we need to know which branch is the latest stable release
#
# - We could make it so merging a PR with a "backport" label attempts to release it, using the target branch as the stable release
# on:
# push:
# branches:
# - master
# # Generate the minor bump
# jobs:
# update_routes:
# runs-on: ubuntu-latest
# steps:
# # Check out the repo, but don't persist credentials, so github uses the GITHUB_TOKEN
# - uses: actions/checkout@v2
# with:
# persist-credentials: false
# # Run cargo workspaces version to generate the version bump PR
# - run: "date > datetime.txt" # create or update a test.txt file
# # And then create the PR
# - uses: gr2m/create-or-update-pull-request-action@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# title: "My pull request title"
# body: "My pull request body"
# branch: "my-pull-request-base-branch"
# path: "lib/"
# commit-message: "My commit message for uncommitted changes in lib/ folder"
# author: "Lorem J. Ipsum <lorem@example.com>"
# labels: label1, label2
# assignees: user1, user2
# reviewers: user1, user2
# team_reviewers: team1, team2
# auto-merge: squash
# update-pull-request-title-and-body: false
# # Generate the major bump
# # # # publish will automatically commit back to the repo **AND** publish to crates.io
# # # # cargo workspaces publish -y ${{ github.event.inputs.semver }}
# name: Deploy Nightly Docs
# on:
# push:
# branches:
# - main
# jobs:
# deploy:
# name: Build & Deploy
# runs-on: ubuntu-latest
# permissions:
# contents: write
# steps:
# - uses: actions/checkout@v4
# - run: sudo apt-get update
# - run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
# - uses: dtolnay/rust-toolchain@nightly
# with:
# toolchain: nightly-2024-02-01
# - uses: Swatinem/rust-cache@v2
# with:
# cache-all-crates: "true"
# save-if: ${{ github.ref == 'refs/heads/main' }}
# - uses: ilammy/setup-nasm@v1
# - name: cargo doc
# run: cargo doc --no-deps --workspace --all-features
# - name: Deploy
# uses: JamesIves/github-pages-deploy-action@v4.5.0
# with:
# branch: gh-pages
# folder: target/doc
# target-folder: api-docs/nightly
# repository-name: dioxuslabs/docsite
# clean: false
# token: ${{ secrets.DEPLOY_KEY }}
# name: docs stable
# on:
# workflow_dispatch:
# concurrency:
# group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
# cancel-in-progress: true
# jobs:
# build-deploy:
# runs-on: ubuntu-latest
# environment: docs
# steps:
# # NOTE: Comment out when https://github.com/rust-lang/mdBook/pull/1306 is merged and released
# # - name: Setup mdBook
# # uses: peaceiris/actions-mdbook@v1
# # with:
# # mdbook-version: "0.4.10"
# # NOTE: Delete when the previous one is enabled
# - name: Setup mdBook
# run: |
# cargo install mdbook --git https://github.com/Demonthos/mdBook.git --branch master
# - uses: actions/checkout@v4
# - name: Build
# run: cd docs &&
# cd guide && mdbook build -d ../nightly/guide && cd .. &&
# cd router && mdbook build -d ../nightly/router && cd ..
# - name: Deploy 🚀
# uses: JamesIves/github-pages-deploy-action@v4.5.0
# with:
# branch: gh-pages # The branch the action should deploy to.
# folder: docs/nightly # The folder the action should deploy.
# target-folder: docs
# repository-name: dioxuslabs/docsite
# clean: false
# token: ${{ secrets.DEPLOY_KEY }} # let's pretend I don't need it for now
# name: Build CLI for Release
# # Will run automatically on every new release
# on:
# release:
# types: [published]
# jobs:
# build-and-upload:
# permissions:
# contents: write
# runs-on: ${{ matrix.platform.os }}
# strategy:
# matrix:
# platform:
# - {
# target: x86_64-pc-windows-msvc,
# os: windows-latest,
# toolchain: "1.70.0",
# }
# - {
# target: x86_64-apple-darwin,
# os: macos-latest,
# toolchain: "1.70.0",
# }
# - {
# target: x86_64-unknown-linux-gnu,
# os: ubuntu-latest,
# toolchain: "1.70.0",
# }
# steps:
# - uses: actions/checkout@v4
# - name: Install stable
# uses: dtolnay/rust-toolchain@master
# with:
# toolchain: ${{ matrix.platform.toolchain }}
# targets: ${{ matrix.platform.target }}
# - uses: ilammy/setup-nasm@v1
# # Setup the Github Actions Cache for the CLI package
# - name: Setup cache
# uses: Swatinem/rust-cache@v2
# with:
# workspaces: packages/cli -> ../../target
# # This neat action can build and upload the binary in one go!
# - name: Build and upload binary
# uses: taiki-e/upload-rust-binary-action@v1
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# target: ${{ matrix.platform.target }}
# bin: dx
# archive: dx-${{ matrix.platform.target }}
# checksum: sha256
# manifest_path: packages/cli/Cargo.toml