Skip to content

release

release #21

Workflow file for this run

name: Publish Package to npmjs
on:
workflow_run:
workflows: ['Test Pipeline']
types:
- completed
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install
run: npm install
- name: Run build
run: npm run build
release:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Setup .npmrc file to publish to npm
- name: Setup Node.JS
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install
- name: Build package
run: npm run build
- name: Publish package
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
tags:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm install
- name: Get version from package.json
id: get_version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Setup GitHub credentials for pushing tags
run: |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/adityadarma/adonis-datatables.git
git checkout main
- name: Create GitHub tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ env.VERSION }}" -m "Release version ${{ env.VERSION }}"
git push origin "v${{ env.VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get merged commits from last tag to current
id: logs
run: |
LAST_TAG=$(git describe --tags --abbrev=0)
echo "Last tag: $LAST_TAG"
LOGS=$(git log ${LAST_TAG}..HEAD --oneline)
echo "LOGS=$LOGS" >> $GITHUB_ENV
- name: Create GitHub release
uses: actions/create-release@v1
with:
tag_name: "v${{ env.VERSION }}"
release_name: "Release v${{ env.VERSION }}"
body: ${{ env.LOGS }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}