Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
add fmt check

Update

cargo fmt

auto format

x

install rustfmt

publish fix

publish

fix

fix

test publish

token

test

test
Fix publishing
  • Loading branch information
tajo committed Jul 5, 2023
1 parent efc2831 commit 91415fc
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 193 deletions.
40 changes: 0 additions & 40 deletions .github/workflows/bump-swc_core.yml

This file was deleted.

59 changes: 12 additions & 47 deletions .github/workflows/cargo.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: Cargo

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

env:
RUST_LOG: debug
Expand All @@ -14,18 +16,11 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest]

name: Test - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- name: Handle line endings
shell: bash
if: runner.os == 'Windows'
run: |
git config --system core.autocrlf false
git config --system core.eol lf
- uses: actions/checkout@v2
with:
submodules: true
Expand All @@ -41,48 +36,18 @@ jobs:
profile: minimal
override: true

- name: Configure path (windows)
shell: bash
if: runner.os == 'Windows'
run: |
echo 'C:\\npm\\prefix' >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
with:
shared-key: "cargo-test"
cache-on-failure: true

- name: Run cargo test
run: |
cargo test --all --color always
publish:
name: "Publish"
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs:
- test
- name: Install rustfmt
run: rustup component add rustfmt

steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true

- name: Install cargo-mono
uses: baptiste0928/cargo-install@v1.1.0
with:
crate: cargo-mono
version: "0.3.1"
locked: true
- name: Run cargo fmt --check
run: |
cargo fmt --all -- --check
- name: Publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Run cargo test
run: |
cargo mono publish --no-verify
cargo test --all --color always
16 changes: 12 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- main
- ci

env:
RUST_LOG: debug
Expand All @@ -14,10 +13,13 @@ jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
persist-credentials: false

- name: Setup node
uses: actions/setup-node@v2
Expand Down Expand Up @@ -53,9 +55,15 @@ jobs:
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Bump versions
shell: bash
run: |
./scripts/bump-all.sh
env:
GH_TOKEN: ${{ secrets.MY_GH_TOKEN }}

- name: Publish npm packages
run: |
npm publish --workspaces --access public
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,10 @@ _fusionPluginI18nChunkTranslationMap.add(
["foo", "test"]
);
```

## Contributing

```sh
cargo build
cargo test
```
3 changes: 1 addition & 2 deletions packages/fusion/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ Then update your `.swcrc` file like below:
[
"swc-plugin-fusion",
{
"displayName": true,
"ssr": true
"ssr": false
}
]
]
Expand Down
4 changes: 4 additions & 0 deletions packages/fusion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"version": "1.0.2",
"description": "SWC plugin for fusion",
"main": "plugin_fusion.wasm",
"publishConfig": {
"access": "public",
"provenance": true
},
"scripts": {
"prepack": "cp ../../target/wasm32-wasi/release/plugin_fusion.wasm ."
},
Expand Down
34 changes: 13 additions & 21 deletions scripts/bump-all.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
#!/usr/bin/env bash
set -eu
set -x

function bumpNpm {
(cd $1 && yarn version --no-git-tag-version --patch)
}
git config --local --unset-all credential.helper
git remote remove origin
git remote add origin https://${GH_TOKEN}@github.com/tajo/swc-plugin-fusion.git

function bumpCargo {
cargo mono bump $1 --breaking
}
echo "Setting git user.name and user.email to last commit author"
git config --global user.name "$(git log -n 1 --pretty=format:%an)"
git config --global user.email "$(git log -n 1 --pretty=format:%ae)"
(cd ./packages/fusion && npm version patch)

CRATES="$(cargo metadata --format-version 1 \
| jq -r '.packages[] | select(.source == null) | .name')"


for PKG in ./packages/fusion; do
bumpNpm $PKG
git commit -a -m "Bump npm package: ${PKG}" || true
done

for CRATE in $CRATES
do
bumpCargo $CRATE
git commit -a -m "Bump cargo crate: ${CRATE}" || true
done
git status
git add .
git commit -m "Bump npm swc-plugin-fusion"
git push origin main
git push origin main --tags
15 changes: 0 additions & 15 deletions scripts/dev/cleanup_test_log.js

This file was deleted.

7 changes: 0 additions & 7 deletions scripts/dev/cleanup_test_log.sh

This file was deleted.

4 changes: 0 additions & 4 deletions scripts/update-bump-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ upgradeCargo -p swc_atoms -p swc_common -p testing -p swc_ecmascript -p swc_ecma

git commit -a -m 'Update swc crates' || true

upgradeCargo -p styled_jsx -p modularize_imports -p swc_emotion

git commit -a -m 'Update extra crates' || true

./scripts/bump-all.sh

# Ensure that Cargo.lock is up-to-date
Expand Down
53 changes: 0 additions & 53 deletions yarn.lock

This file was deleted.

0 comments on commit 91415fc

Please sign in to comment.