diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9553291..aa723dd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,46 +1,77 @@ -name: Scram My Shit +name: CI on: push: - branches: - - main pull_request: - branches: - - main jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v4 - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: '18' - - - name: Install dependencies - run: npm install + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "22" + - name: Setup Rust Toolchain + run: | + rustup toolchain install stable --profile minimal + rustup target add wasm32-unknown-unknown + cargo install wasm-bindgen-cli + sudo apt-get update && sudo apt-get install -y binaryen - - name: Setup Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable + - name: Install dependencies + run: npm install - - name: Install wasm32 toolchain - run: rustup target add wasm32-unknown-unknown + - name: Build Rewriter + run: npm run rewriter:build - - name: Install wasm-bindgen-cli - run: cargo install wasm-bindgen-cli - - - name: Install wasm-opt - run: sudo apt-get update && sudo apt-get install -y binaryen - - - name: Build Rewriter - run: npm run rewriter:build + - name: Build Scramjet + run: npm run build + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: scramjet + path: | + dist/*.js + dist/*.js.map - - name: Run npm build - run: npm run build + upload: + name: Upload release + runs-on: ubuntu-latest + needs: build + if: github.ref == 'refs/heads/main' + + steps: + - name: Delete old release and tag + uses: dev-drprasad/delete-tag-and-release@v1.0.1 + with: + delete_release: true + tag_name: latest + github_token: ${{ github.token }} + + - name: Get artifacts + uses: actions/download-artifact@v3 + with: + name: scramjet + path: build + + - name: Display structure of downloaded files + run: ls -R + + - name: Zip files + run: zip -r scramjet.zip build/ + + - name: Release to GitHub + uses: ncipollo/release-action@v1 + with: + name: Continuous Build + tag: latest + commit: main + body: ${{ github.event.head_commit.message }} + artifacts: "scramjet.zip" + prerelease: true diff --git a/package.json b/package.json index b970bd9..b1e126a 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "build": "rspack build --mode production", "rewriter:build": "cd rewriter && bash build.sh && cd ..", "dev": "node server.js", - "prepublish": "npm run build", + "prepack": "npm run build", "pub": "npm publish --no-git-checks --access public", "format": "prettier --config .prettierrc.js --write .", "lint": "eslint ./src/",