Break out windows sed in CI action Add run-script-os, break apart find-replace for each Fix importmeta command typos Fix windows commands in packag.json and ci.yml I actually ran these on my windows machine Update package.json call remove-import-meta from ci fucking sed updates only remove import meta pre tests updates fix order Signed-off-by: Jess Frazelle <github@jessfraz.com>
		
			
				
	
	
		
			278 lines
		
	
	
		
			9.3 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			278 lines
		
	
	
		
			9.3 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
name: CI
 | 
						|
 | 
						|
on:
 | 
						|
  pull_request:
 | 
						|
  push:
 | 
						|
    branches:
 | 
						|
      - main
 | 
						|
  release:
 | 
						|
    types: [published]
 | 
						|
 | 
						|
jobs:
 | 
						|
  check-format:
 | 
						|
    runs-on: 'ubuntu-20.04'
 | 
						|
    steps:
 | 
						|
      - uses: actions/checkout@v4
 | 
						|
      - uses: actions/setup-node@v3
 | 
						|
        with:
 | 
						|
          node-version-file: '.nvmrc'
 | 
						|
          cache: 'yarn'
 | 
						|
      - run: yarn install
 | 
						|
      - run: yarn fmt-check
 | 
						|
 | 
						|
  check-types:
 | 
						|
    runs-on: ubuntu-20.04
 | 
						|
 | 
						|
    steps:
 | 
						|
      - uses: actions/checkout@v4
 | 
						|
      - uses: actions/setup-node@v3
 | 
						|
        with:
 | 
						|
          node-version-file: '.nvmrc'
 | 
						|
          cache: 'yarn'
 | 
						|
      - run: yarn install
 | 
						|
      - uses: Swatinem/rust-cache@v2
 | 
						|
        with:
 | 
						|
          workspaces: './src/wasm-lib'
 | 
						|
 | 
						|
      - run: yarn build:wasm
 | 
						|
      - run: yarn tsc
 | 
						|
 | 
						|
  build-test-web:
 | 
						|
    runs-on: ubuntu-20.04
 | 
						|
    outputs:
 | 
						|
      version: ${{ steps.export_version.outputs.version }}
 | 
						|
    steps:
 | 
						|
      - uses: actions/checkout@v4
 | 
						|
 | 
						|
      - uses: actions/setup-node@v3
 | 
						|
        with:
 | 
						|
          node-version-file: '.nvmrc'
 | 
						|
          cache: 'yarn'
 | 
						|
 | 
						|
      - run: yarn install
 | 
						|
 | 
						|
      - uses: Swatinem/rust-cache@v2
 | 
						|
        with:
 | 
						|
          workspaces: './src/wasm-lib'
 | 
						|
 | 
						|
      - run: yarn build:wasm
 | 
						|
 | 
						|
      - run: yarn simpleserver:ci
 | 
						|
 | 
						|
      - run: yarn test:nowatch
 | 
						|
 | 
						|
      - run: yarn test:cov
 | 
						|
 | 
						|
      - id: export_version
 | 
						|
        run: echo "version=`cat package.json | jq -r '.version'`" >> "$GITHUB_OUTPUT"
 | 
						|
 | 
						|
  build-apps:
 | 
						|
    needs: [check-format, build-test-web, check-types]
 | 
						|
    runs-on: ${{ matrix.os }}
 | 
						|
    strategy:
 | 
						|
      matrix:
 | 
						|
        os: [macos-latest, ubuntu-20.04, windows-latest]
 | 
						|
    steps:
 | 
						|
      - uses: actions/checkout@v4
 | 
						|
 | 
						|
      - name: install ubuntu system dependencies
 | 
						|
        if: matrix.os == 'ubuntu-20.04'
 | 
						|
        run: |
 | 
						|
          sudo apt-get update
 | 
						|
          sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libayatana-appindicator3-dev librsvg2-dev
 | 
						|
 | 
						|
      - name: Sync node version and setup cache
 | 
						|
        uses: actions/setup-node@v3
 | 
						|
        with:
 | 
						|
          node-version-file: '.nvmrc'
 | 
						|
          cache: 'yarn' # Set this to npm, yarn or pnpm.
 | 
						|
 | 
						|
      - run: yarn install
 | 
						|
 | 
						|
      - name: Rust setup
 | 
						|
        uses: dtolnay/rust-toolchain@stable
 | 
						|
 | 
						|
      - name: Rust cache
 | 
						|
        uses: swatinem/rust-cache@v2
 | 
						|
        with:
 | 
						|
          workspaces: './src-tauri -> target'
 | 
						|
 | 
						|
      - uses: Swatinem/rust-cache@v2
 | 
						|
        with:
 | 
						|
          workspaces: './src/wasm-lib'
 | 
						|
 | 
						|
      - name: wasm prep
 | 
						|
        shell: bash
 | 
						|
        run: |
 | 
						|
          mkdir src/wasm-lib/pkg; cd src/wasm-lib
 | 
						|
          npx wasm-pack build --target web --out-dir pkg
 | 
						|
          cd ../../
 | 
						|
          cp src/wasm-lib/pkg/wasm_lib_bg.wasm public
 | 
						|
 | 
						|
      - name: Fix format
 | 
						|
        run: yarn fmt
 | 
						|
 | 
						|
      - name: install apple silicon target mac
 | 
						|
        if: matrix.os == 'macos-latest'
 | 
						|
        run: |
 | 
						|
          rustup target add aarch64-apple-darwin
 | 
						|
 | 
						|
      - name: Prepare Windows certificate and variables
 | 
						|
        if: matrix.os == 'windows-latest'
 | 
						|
        run: |
 | 
						|
          echo "${{secrets.SM_CLIENT_CERT_FILE_B64 }}" | base64 --decode > /d/Certificate_pkcs12.p12
 | 
						|
          cat /d/Certificate_pkcs12.p12
 | 
						|
          echo "::set-output name=version::${GITHUB_REF#refs/tags/v}"
 | 
						|
          echo "SM_HOST=${{ secrets.SM_HOST }}" >> "$GITHUB_ENV"
 | 
						|
          echo "SM_API_KEY=${{ secrets.SM_API_KEY }}" >> "$GITHUB_ENV"
 | 
						|
          echo "SM_CLIENT_CERT_FILE=D:\\Certificate_pkcs12.p12" >> "$GITHUB_ENV"
 | 
						|
          echo "SM_CLIENT_CERT_PASSWORD=${{ secrets.SM_CLIENT_CERT_PASSWORD }}" >> "$GITHUB_ENV"
 | 
						|
          echo "C:\Program Files (x86)\Windows Kits\10\App Certification Kit" >> $GITHUB_PATH
 | 
						|
          echo "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools" >> $GITHUB_PATH
 | 
						|
          echo "C:\Program Files\DigiCert\DigiCert One Signing Manager Tools" >> $GITHUB_PATH
 | 
						|
        shell: bash
 | 
						|
 | 
						|
      - name: Setup Windows certicate with SSM KSP
 | 
						|
        if: matrix.os == 'windows-latest'
 | 
						|
        run: |
 | 
						|
          curl -X GET  https://one.digicert.com/signingmanager/api-ui/v1/releases/smtools-windows-x64.msi/download -H "x-api-key:%SM_API_KEY%" -o smtools-windows-x64.msi
 | 
						|
          msiexec /i smtools-windows-x64.msi /quiet /qn
 | 
						|
          smksp_registrar.exe list
 | 
						|
          smctl.exe keypair ls
 | 
						|
          C:\Windows\System32\certutil.exe -csp "DigiCert Signing Manager KSP" -key -user
 | 
						|
          smksp_cert_sync.exe
 | 
						|
        shell: cmd
 | 
						|
 | 
						|
      - name: Build and sign the app for the current platform
 | 
						|
        uses: tauri-apps/tauri-action@v0
 | 
						|
        env:
 | 
						|
          TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
 | 
						|
          TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
 | 
						|
          APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
 | 
						|
          APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
 | 
						|
          APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
 | 
						|
          APPLE_ID: ${{ secrets.APPLE_ID }}
 | 
						|
          APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
 | 
						|
        with:
 | 
						|
          args: ${{ matrix.os == 'macos-latest' && '--target universal-apple-darwin' || '' }}
 | 
						|
 | 
						|
      - uses: actions/upload-artifact@v3
 | 
						|
        with:
 | 
						|
          path: ${{ matrix.os == 'macos-latest' && 'src-tauri/target/universal-apple-darwin/release/bundle/*/*' || 'src-tauri/target/release/bundle/*/*' }}
 | 
						|
 | 
						|
  publish-apps-release:
 | 
						|
    runs-on: ubuntu-20.04
 | 
						|
    if: github.event_name == 'release'
 | 
						|
    needs: [build-test-web, build-apps]
 | 
						|
    env:
 | 
						|
      VERSION_NO_V: ${{ needs.build-test-web.outputs.version }}
 | 
						|
      PUB_DATE: ${{ github.event.release.created_at }}
 | 
						|
      NOTES: ${{ github.event.release.body }}
 | 
						|
    steps:
 | 
						|
      - uses: actions/download-artifact@v3
 | 
						|
 | 
						|
      - name: Generate the update static endpoint
 | 
						|
        run: |
 | 
						|
          ls -l artifact/*/*itty*
 | 
						|
          DARWIN_SIG=`cat artifact/macos/*.app.tar.gz.sig`
 | 
						|
          LINUX_SIG=`cat artifact/appimage/*.AppImage.tar.gz.sig`
 | 
						|
          WINDOWS_SIG=`cat artifact/msi/*.msi.zip.sig`
 | 
						|
          RELEASE_DIR=https://dl.kittycad.io/releases/modeling-app/v${VERSION_NO_V}
 | 
						|
          jq --null-input \
 | 
						|
            --arg version "v${VERSION_NO_V}" \
 | 
						|
            --arg pub_date "${PUB_DATE}" \
 | 
						|
            --arg notes "${NOTES}" \
 | 
						|
            --arg darwin_sig "$DARWIN_SIG" \
 | 
						|
            --arg darwin_url "$RELEASE_DIR/macos/KittyCAD%20Modeling.app.tar.gz" \
 | 
						|
            --arg linux_sig "$LINUX_SIG" \
 | 
						|
            --arg linux_url "$RELEASE_DIR/appimage/kittycad-modeling_${VERSION_NO_V}_amd64.AppImage.tar.gz" \
 | 
						|
            --arg windows_sig "$WINDOWS_SIG" \
 | 
						|
            --arg windows_url "$RELEASE_DIR/msi/KittyCAD%20Modeling_${VERSION_NO_V}_x64_en-US.msi.zip" \
 | 
						|
            '{
 | 
						|
              "version": $version,
 | 
						|
              "pub_date": $pub_date,
 | 
						|
              "notes": $notes,
 | 
						|
              "platforms": {
 | 
						|
                "darwin-x86_64": {
 | 
						|
                  "signature": $darwin_sig,
 | 
						|
                  "url": $darwin_url
 | 
						|
                },
 | 
						|
                "darwin-aarch64": {
 | 
						|
                  "signature": $darwin_sig,
 | 
						|
                  "url": $darwin_url
 | 
						|
                },
 | 
						|
                "linux-x86_64": {
 | 
						|
                  "signature": $linux_sig,
 | 
						|
                  "url": $linux_url
 | 
						|
                },
 | 
						|
                "windows-x86_64": {
 | 
						|
                  "signature": $windows_sig,
 | 
						|
                  "url": $windows_url
 | 
						|
                }
 | 
						|
              }
 | 
						|
            }' > last_update.json
 | 
						|
            cat last_update.json
 | 
						|
 | 
						|
      - name: Generate the download static endpoint
 | 
						|
        run: |
 | 
						|
          RELEASE_DIR=https://dl.kittycad.io/releases/modeling-app/v${VERSION_NO_V}
 | 
						|
          jq --null-input \
 | 
						|
            --arg version "v${VERSION_NO_V}" \
 | 
						|
            --arg pub_date "${PUB_DATE}" \
 | 
						|
            --arg notes "${NOTES}" \
 | 
						|
            --arg darwin_url "$RELEASE_DIR/dmg/KittyCAD%20Modeling_${VERSION_NO_V}_universal.dmg" \
 | 
						|
            --arg linux_url "$RELEASE_DIR/appimage/kittycad-modeling_${VERSION_NO_V}_amd64.AppImage" \
 | 
						|
            --arg windows_url "$RELEASE_DIR/msi/KittyCAD%20Modeling_${VERSION_NO_V}_x64_en-US.msi" \
 | 
						|
            '{
 | 
						|
              "version": $version,
 | 
						|
              "pub_date": $pub_date,
 | 
						|
              "notes": $notes,
 | 
						|
              "platforms": {
 | 
						|
                "dmg-universal": {
 | 
						|
                  "url": $darwin_url
 | 
						|
                },
 | 
						|
                "appimage-x86_64": {
 | 
						|
                  "url": $linux_url
 | 
						|
                },
 | 
						|
                "msi-x86_64": {
 | 
						|
                  "url": $windows_url
 | 
						|
                }
 | 
						|
              }
 | 
						|
            }' > last_download.json
 | 
						|
            cat last_download.json
 | 
						|
 | 
						|
      - name: Authenticate to Google Cloud
 | 
						|
        uses: 'google-github-actions/auth@v1.1.1'
 | 
						|
        with:
 | 
						|
          credentials_json: '${{ secrets.GOOGLE_CLOUD_DL_SA }}'
 | 
						|
 | 
						|
      - name: Set up Google Cloud SDK
 | 
						|
        uses: google-github-actions/setup-gcloud@v1.1.1
 | 
						|
        with:
 | 
						|
          project_id: kittycadapi
 | 
						|
 | 
						|
      - name: Upload release files to public bucket
 | 
						|
        uses: google-github-actions/upload-cloud-storage@v1.0.3
 | 
						|
        with:
 | 
						|
          path: artifact
 | 
						|
          glob: '*/*itty*'
 | 
						|
          parent: false
 | 
						|
          destination: dl.kittycad.io/releases/modeling-app/v${{ env.VERSION_NO_V }}
 | 
						|
 | 
						|
      - name: Upload update endpoint to public bucket
 | 
						|
        uses: google-github-actions/upload-cloud-storage@v1.0.3
 | 
						|
        with:
 | 
						|
          path: last_update.json
 | 
						|
          destination: dl.kittycad.io/releases/modeling-app
 | 
						|
 | 
						|
      - name: Upload download endpoint to public bucket
 | 
						|
        uses: google-github-actions/upload-cloud-storage@v1.0.3
 | 
						|
        with:
 | 
						|
          path: last_download.json
 | 
						|
          destination: dl.kittycad.io/releases/modeling-app
 | 
						|
 | 
						|
      - name: Upload release files to Github
 | 
						|
        uses: softprops/action-gh-release@v1
 | 
						|
        with:
 | 
						|
          files: artifact/*/*itty*
 |