Browse Source

upload dx on every branch

Jonathan Kelley 4 days ago
parent
commit
59fc452a1a
3 changed files with 100 additions and 5 deletions
  1. 19 3
      .github/install.sh
  2. 81 0
      .github/workflows/main.yml
  3. 0 2
      packages/cli/Cargo.toml

+ 19 - 3
.github/install.sh

@@ -47,8 +47,8 @@ success() {
 command -v unzip >/dev/null ||
     error 'unzip is required to install dx'
 
-if [[ $# -gt 1 ]]; then
-    error 'Too many arguments, only 1 are allowed. The first can be a specific tag of dx to install. (e.g. "dx-v0.7.1")'
+if [[ $# -gt 2 ]]; then
+    error 'Too many arguments, only 2 are allowed. The first can be a specific tag of dx to install. (e.g. "dx-v0.7.1") or `nightly` or `pr <PR_NUMBER>` to install the latest nightly or PR build.'
 fi
 
 if [ "$OS" = "Windows_NT" ]; then
@@ -81,7 +81,23 @@ exe_name=dx
 if [[ $# = 0 ]]; then
     dx_uri=$github_repo/releases/latest/download/dx-$target.zip
 else
-    dx_uri=$github_repo/releases/download/$1/dx-$target.zip
+    if [[ $1 = "nightly" ]]; then
+        echo "Installing latest nightly build for target $target"
+
+        # get the artifact ID and then run id by grepping. There will be two results, one for the worfklow id and one for the artifact ID.
+
+        # list=$(curl --fail --location --progress-bar  -L "https://api.github.com/repos/dioxuslabs/dioxus/actions/artifacts?name=playwright-report-1.86.0-macOS")
+        list=$(curl --fail --location --progress-bar  -L "https://api.github.com/repos/dioxuslabs/dioxus/actions/artifacts?name=dx-$target-nightly")
+        artifact_id=$(echo $list | grep -o '"id": [0-9]*' | head -2 | cut -d' ' -f2 | head -1)
+        workflow_id=$(echo $list | grep -o '"id": [0-9]*' | head -2 | cut -d' ' -f2 | tail -1)
+        echo "Artifact ID: $artifact_id"
+        echo "Workflow ID: $workflow_id"
+
+        # https://github.com/DioxusLabs/dioxus/actions/runs/16174794892/artifacts/3497286082
+        dx_uri=$github_repo/actions/runs/$workflow_id/artifacts/$artifact_id
+    else
+        dx_uri=$github_repo/releases/download/$1/dx-$target.zip
+    fi
 fi
 
 dx_install="${DX_INSTALL:-$HOME/.dx}"

+ 81 - 0
.github/workflows/main.yml

@@ -374,6 +374,87 @@ jobs:
         run: |
           cargo test --workspace --tests
 
+  # Releases for the CLI on a per-branch basis
+  nightly-cli:
+    permissions:
+      contents: write
+    runs-on: ${{ matrix.platform.os }}
+    strategy:
+      matrix:
+        platform:
+          - target: x86_64-pc-windows-msvc
+            os: windows-latest
+          - target: aarch64-pc-windows-msvc
+            os: windows-latest
+          - target: x86_64-apple-darwin
+            os: macos-13
+          - target: aarch64-apple-darwin
+            os: macos-latest
+          - target: x86_64-unknown-linux-gnu
+            os: ubuntu-24.04
+          - target: aarch64-unknown-linux-gnu
+            os: ubuntu-24.04-arm
+          - target: x86_64-unknown-linux-musl
+            os: ubuntu-24.04
+          - target: aarch64-unknown-linux-musl
+            os: ubuntu-24.04-arm
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v4
+
+      - name: Install openssl on macos
+        if: matrix.platform.os == 'macos-latest'
+        run: brew install openssl
+
+      - name: Install nasm for windows (tls)
+        if: ${{ matrix.platform.target == 'x86_64-pc-windows-msvc' }}
+        uses: ilammy/setup-nasm@v1
+
+      - name: Free Disk Space
+        if: ${{ matrix.platform.os == 'ubuntu-24.04' || matrix.platform.os == 'ubuntu-24.04-arm' }}
+        uses: ./.github/actions/free-disk-space
+
+      - uses: awalsh128/cache-apt-pkgs-action@latest
+        if: ${{ matrix.platform.os == 'ubuntu-24.04' || matrix.platform.os == 'ubuntu-24.04-arm' }}
+        with:
+          packages: libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev libglib2.0-dev musl-tools
+          version: 1.0
+
+      - name: Install stable
+        uses: dtolnay/rust-toolchain@master
+        with:
+          toolchain: "1.86.0"
+          targets: ${{ matrix.platform.target }}
+
+      - uses: Swatinem/rust-cache@v2
+        with:
+          cache-all-crates: "true"
+          save-if: ${{ github.ref == 'refs/heads/main' }}
+
+      - 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 CLI
+        run: |
+          cargo build --release --package dioxus-cli --target ${{ matrix.platform.target }}
+
+      - name: Upload CLI binaries
+      - uses: actions/upload-artifact@v4
+        if: always()
+        with:
+          name: dx-${{ matrix.platform.target }}-${{ github.event.number || "nightly" }}
+          path: ./target/${{ matrix.platform.target }}/release/dx
+          retention-days: ${{ github.ref == 'refs/heads/main' && 90 || 30 }}
+          overwrite: true
+
+      - name: Output artifact ID
+        run:  echo 'Artifact ID is ${{ steps.artifact-upload-step.outputs.artifact-id }}'
+
   # Only run semver checks if the PR is not a draft and does not have the breaking label
   # Breaking PRs don't need to follow semver since they are breaking changes
   # However, this means we won't attempt to backport them, so you should be careful about using this label, as it will

+ 0 - 2
packages/cli/Cargo.toml

@@ -149,9 +149,7 @@ built = { version = "0.7.5", features = ["git2"] }
 
 [features]
 default = []
-plugin = []
 tokio-console = ["dep:console-subscriber", "tokio/tracing"]
-bundle = []
 no-downloads = []
 
 [[bin]]