Skip to content

Commit

Permalink
chore: update ci workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari committed Feb 1, 2024
1 parent a631fc7 commit edb02d1
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 60 deletions.
101 changes: 57 additions & 44 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,58 @@ env:
RUST_LOG: "off"

jobs:
publish-npm:
if: startsWith(github.ref, 'refs/tags/v')
wasm-build:
name: Wasm build
runs-on: ubuntu-latest
permissions:
id-token: write
strategy:
matrix:
crate: ["biome_fmt", "web_fmt"]
steps:
- uses: actions/checkout@v4

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Build wasm
- name: Build ${{matrix.crate}} wasm
run: |
./crates/biome_fmt/scripts/build.sh
./crates/web_fmt/scripts/build.sh
./crates/${{ matrix.crate }}/scripts/build.sh
- name: Package ${{matrix.crate}}
working-directory: crates/${{matrix.crate}}/pkg
run: npm pack

- name: Upload ${{matrix.crate}}
uses: actions/upload-artifact@v4
with:
name: ${{matrix.crate}}
path: |
crates/${{matrix.crate}}/pkg
# To keep the pkg directory structure
crates/${{matrix.crate}}/README.md
publish-npm:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
id-token: write
strategy:
matrix:
crate: ["biome_fmt", "web_fmt"]
steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: ${{matrix.crate}}
path: crates/${{matrix.crate}}

- uses: actions/setup-node@v4
with:
node-version-file: ".node-version"
registry-url: "https://registry.npmjs.org"

- name: Publish biome_fmt
working-directory: crates/biome_fmt/pkg
run: npm publish --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish web_fmt
working-directory: crates/web_fmt/pkg
- name: Publish ${{matrix.crate}}
working-directory: crates/${{matrix.crate}}/pkg
run: npm publish --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand All @@ -49,30 +72,24 @@ jobs:
runs-on: ubuntu-latest
permissions:
packages: write
strategy:
matrix:
crate: ["biome_fmt", "web_fmt"]
steps:
- uses: actions/checkout@v4

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Build wasm
run: |
./crates/biome_fmt/scripts/build.sh
./crates/web_fmt/scripts/build.sh
- uses: actions/download-artifact@v4
with:
name: ${{matrix.crate}}
path: crates/${{matrix.crate}}

- uses: actions/setup-node@v4
with:
node-version-file: ".node-version"
registry-url: "https://npm.pkg.github.com"

- name: Publish biome_fmt
working-directory: crates/biome_fmt/pkg
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish web_fmt
working-directory: crates/web_fmt/pkg
- name: Publish ${{matrix.crate}}
working-directory: crates/${{matrix.crate}}/pkg
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -82,28 +99,24 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
crate: ["biome_fmt", "web_fmt"]
steps:
- uses: actions/checkout@v4

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Build wasm
run: |
./crates/biome_fmt/scripts/build.sh
./crates/web_fmt/scripts/build.sh
- name: Package biome_fmt
working-directory: crates/biome_fmt/pkg
run: npm pack
- uses: actions/download-artifact@v4
with:
name: ${{matrix.crate}}
path: crates/${{matrix.crate}}

- name: Package web_fmt
working-directory: crates/web_fmt/pkg
- name: Package ${{matrix.crate}}
working-directory: crates/${{matrix.crate}}/pkg
run: npm pack

- name: Release
uses: softprops/action-gh-release@c9b46fe7aad9f02afd89b12450b780f52dacfb2d
with:
files: |
crates/*/pkg/*.tgz
crates/*/pkg/*.wasm
crates/*/pkg/*.wasm
37 changes: 21 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Test

on: [push, pull_request]
on:
push:
branches:
- "*"
pull_request:
types: ["opened", "reopened", "synchronize"]

env:
CARGO_INCREMENTAL: 0
Expand Down Expand Up @@ -34,31 +39,31 @@ jobs:
wasm-build:
name: Wasm build
runs-on: ubuntu-latest
strategy:
matrix:
crate: ["biome_fmt", "web_fmt"]
steps:
- uses: actions/checkout@v4

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Build wasm
- name: Build ${{matrix.crate}} wasm
run: |
./crates/biome_fmt/scripts/build.sh
./crates/web_fmt/scripts/build.sh
./crates/${{ matrix.crate }}/scripts/build.sh
- name: Package biome_fmt
working-directory: crates/biome_fmt/pkg
- name: Package ${{matrix.crate}}
working-directory: crates/${{matrix.crate}}/pkg
run: npm pack

- name: Package web_fmt
working-directory: crates/web_fmt/pkg
run: npm pack

- name: Upload
- name: Upload ${{matrix.crate}}
uses: actions/upload-artifact@v4
with:
name: ${{matrix.crate}}
path: |
crates/biome_fmt/pkg
crates/web_fmt/pkg
crates/${{matrix.crate}}/pkg
# To keep the pkg directory structure
crates/${{matrix.crate}}/README.md
node-test:
runs-on: ubuntu-latest
Expand All @@ -67,7 +72,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: crates/
path: crates

- uses: actions/setup-node@v4
with:
Expand All @@ -82,7 +87,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: crates/
path: crates

- uses: denoland/setup-deno@v1
with:
Expand All @@ -97,7 +102,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: crates/
path: crates

- uses: oven-sh/setup-bun@v1
name: Install bun
Expand Down

0 comments on commit edb02d1

Please sign in to comment.