feat: 新版国际化API #256
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto Release and Publish via package version | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'package.json' | |
| jobs: | |
| Version: | |
| name: Analysis Version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version_changed: ${{ steps.detect.outputs.version_changed }} | |
| current_version: ${{ steps.detect.outputs.current_version }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Detect version change | |
| id: detect | |
| run: | | |
| CURRENT_VERSION=$(jq -r .version package.json) | |
| echo "Current version: $CURRENT_VERSION" | |
| git checkout HEAD~1 -- package.json 2>/dev/null || true | |
| PREVIOUS_VERSION=$(jq -r .version package.json 2>/dev/null || echo "0.0.0") | |
| echo "Previous version: $PREVIOUS_VERSION" | |
| if [[ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]]; then | |
| echo "version_changed=true" >> $GITHUB_OUTPUT | |
| echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| else | |
| echo "version_changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| Release: | |
| name: Release and Tag | |
| needs: Version | |
| if: ${{ needs.Version.outputs.version_changed == 'true' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Create Release and Tag | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ needs.Version.outputs.current_version }} | |
| release_name: v${{ needs.Version.outputs.current_version }} | |
| body: 'Install: https://www.npmjs.com/package/next-flow-interface' | |
| draft: false | |
| prerelease: false | |
| Publish: | |
| name: Publish to NPM | |
| needs: Version | |
| if: ${{ needs.Version.outputs.version_changed == 'true' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun Environment | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: 'latest' | |
| - name: Install Dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Run Unit Tests | |
| run: bun run test | |
| - name: Build Project | |
| run: bun run build | |
| - name: Setup NodeJs for NPM | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 'latest' | |
| registry-url: 'https://registry.npmjs.org/' | |
| - name: Publish to NPM | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | |
| Packages: | |
| name: Publish to GitHub | |
| needs: Version | |
| if: ${{ needs.Version.outputs.version_changed == 'true' }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun Environment | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: 'latest' | |
| - name: Install Dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Run Unit Tests | |
| run: bun run test | |
| - name: Build Project | |
| run: bun run build | |
| - name: Add scope to package.json | |
| run: | | |
| sudo apt-get install -y jq | |
| cp package.json package.json.bak | |
| jq '.name = "@NEXT-FLOW/\(.name)" | .repository.url = "git+https://github.com/rhineai/rhine-var.git"' package.json > package.json.tmp | |
| mv package.json.tmp package.json | |
| jq empty package.json | |
| - name: Setup NodeJs for NPM | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 'latest' | |
| - name: Configure Github NPM Registry | |
| run: | | |
| npm config set @NEXT-FLOW:registry=https://npm.pkg.github.com | |
| echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> ~/.npmrc | |
| - name: Publish to Github | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} |