diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 9c4a376..bb047a7 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -6,8 +6,9 @@ name: Node.js Package on: release: types: [created] - workflow_dispatch: + workflow_run: + workflows: release jobs: build: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..077ba2b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,46 @@ +name: Create Release + +on: + push: + workflow_dispatch: + +jobs: + create-release: + runs-on: ubuntu-latest + + steps: + # Step 1: Check out the code + - name: Checkout code + uses: actions/checkout@v4 + + # Step 2: Set up Node.js + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '16' # Use the latest LTS version of Node.js + + # Step 3: Read the version from package.json + - name: Get version from package.json + id: get_version + run: | + PACKAGE_VERSION=$(node -p "require('./package.json').version") + echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV + + # Step 4: Create the tag + - name: Create tag + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag -a "${PACKAGE_VERSION}" -m "Release ${PACKAGE_VERSION}" + git push origin "${PACKAGE_VERSION}" + + # Step 5: Create GitHub release + - name: Create GitHub Release + uses: actions/create-release@v1 + with: + tag_name: "${{ env.PACKAGE_VERSION }}" + release_name: "Release ${{ env.PACKAGE_VERSION }}" + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}