diff --git a/.github/workflows/npm_release.yml b/.github/workflows/npm_release.yml new file mode 100644 index 0000000..4eca4b0 --- /dev/null +++ b/.github/workflows/npm_release.yml @@ -0,0 +1,55 @@ +on: + workflow_call: + inputs: + branch: + required: true + type: string + tag: + required: true + type: string + version-args: + required: true + type: string + secrets: + NPM_TOKEN: + required: true + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "path=$(yarn cache dir)" >> $GITHUB_OUTPUT + - uses: actions/cache@v3 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.path }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Run install + run: yarn install --frozen-lockfile + + # Ref: https://github.com/actions/checkout/blob/main/README.md#push-a-commit-using-the-built-in-token + - name: Set up github actions user + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + - name: Run npm version + run: npm version ${{ inputs.version-args }} + + - name: Git push + run: | + git push origin ${{ inputs.branch }} + git push --tags + + - name: Release to NPM + uses: JS-DevTools/npm-publish@v3 + with: + token: ${{ secrets.NPM_TOKEN }} + tag: ${{ inputs.tag }} diff --git a/.github/workflows/release_alpha.yml b/.github/workflows/release_alpha.yml new file mode 100644 index 0000000..4348548 --- /dev/null +++ b/.github/workflows/release_alpha.yml @@ -0,0 +1,13 @@ +on: + push: + branches: alpha + +jobs: + release: + uses: reearth/core/.github/workflows/npm_release.yml@main + with: + branch: alpha + tag: alpha + version-args: --preid alpha prerelease + secrets: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release_beta.yml b/.github/workflows/release_beta.yml new file mode 100644 index 0000000..6df03ab --- /dev/null +++ b/.github/workflows/release_beta.yml @@ -0,0 +1,13 @@ +on: + push: + branches: beta + +jobs: + release: + uses: reearth/core/.github/workflows/npm_release.yml@main + with: + branch: beta + tag: beta + version-args: --preid beta prerelease + secrets: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release_latest.yml b/.github/workflows/release_latest.yml new file mode 100644 index 0000000..a29f79f --- /dev/null +++ b/.github/workflows/release_latest.yml @@ -0,0 +1,20 @@ +on: + workflow_dispatch: + inputs: + version-type: + required: true + type: choice + options: + - major + - minor + - patch + +jobs: + release: + uses: reearth/core/.github/workflows/npm_release.yml@main + with: + branch: main + tag: latest + version-args: ${{ inputs.version-type }} + secrets: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index d89a486..a0b53a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@reearth/core", - "version": "0.0.4", + "version": "0.0.5-beta.0", "author": "Re:Earth contributors ", "license": "Apache-2.0", "description": "A library that abstracts a map engine as one common API.", @@ -19,7 +19,9 @@ "preview": "vite preview", "test": "vitest", "storybook": "storybook dev -p 6007", - "build-storybook": "storybook build" + "build-storybook": "storybook build", + "preversion": "yarn test run", + "version": "yarn build" }, "engines": { "node": ">=20"