add release function #1
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: Create Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "18" | |
- name: Get version from package.json | |
id: package-version | |
uses: martinbeentjes/npm-get-version-action@master | |
- name: Create Release | |
id: create_release | |
uses: ncipollo/release-action@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag: v${{ steps.package-version.outputs.current-version }} | |
name: Release ${{ steps.package-version.outputs.current-version }} | |
draft: false | |
prerelease: false | |
- name: Update major version tag | |
run: | | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
MAJOR_VERSION=$(echo ${{ steps.package-version.outputs.current-version }} | cut -d. -f1) | |
git tag -fa v${MAJOR_VERSION} -m "Update v${MAJOR_VERSION} tag" | |
git push origin v${MAJOR_VERSION} --force |