build_release #18
This file contains 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: build_release | |
on: push | |
jobs: | |
build_release: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- uses: pnpm/action-setup@v2 | |
- run: pnpm install | |
- run: pnpm run build | |
- id: version | |
run: | | |
version=$(pnpm exec tsx ./scripts/showVersion.ts) | |
echo "version=${version}" >> "$GITHUB_OUTPUT" | |
- name: Git commit | |
id: commit | |
run: | | |
git config --local user.email github-actions[bot]@users.noreply.github.com | |
git config --local user.name github-actions[bot] | |
git config --global core.autocrlf true | |
git config --global core.safecrlf false | |
git status | |
git add . | |
git commit -a -m "chore: v${{steps.version.outputs.version}}" | |
continue-on-error: true | |
- name: Git push | |
if: ${{ steps.commit.outcome == 'success' }} | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} | |
tags: true | |
- name: Create Release | |
id: create_release | |
if: ${{ steps.commit.outcome == 'success' }} | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ steps.version.outputs.version }} | |
release_name: Release ${{ steps.version.outputs.version }} | |
body_path: ./CHANGELOG.md | |
- name: Publish package | |
if: ${{ steps.commit.outcome == 'success' }} | |
run: | | |
pnpm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }} | |
pnpm publish | |
- name: sync npmmirror | |
if: ${{ steps.commit.outcome == 'success' }} | |
run: curl -X PUT 'https://registry-direct.npmmirror.com/@wenbux/gkd_subscription/sync' | |
- name: Upload Release Asset | |
id: upload-release-asset | |
if: ${{ steps.create_release.outcome == 'success' }} | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist/gkd.json5 | |
asset_name: gkd_${{ steps.version.outputs.version }}.json5 | |
asset_content_type: application/json |