Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 41 additions & 14 deletions .github/workflows/node-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,62 @@ jobs:
node-version: "16"

- name: Install dependencies
run: npm ci
run: |
npm ci
npm install -g postcss-cli

- name: Build the package
run: npm run build

- name: Publish to npm
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
npm publish

tag:
runs-on: ubuntu-latest
create_release:
name: Create Release
needs: build
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'

runs-on: ubuntu-latest
permissions:
contents: write
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get version and create tag
id: version
run: |
VERSION="0.1.$(date +%Y%m%d)-$(git rev-parse --short HEAD)"
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "TAG_NAME=v${VERSION}" >> $GITHUB_OUTPUT
if git tag -l "v${VERSION}" | grep -q "v${VERSION}"; then
echo "TAG_EXISTS=true" >> $GITHUB_OUTPUT
else
echo "TAG_EXISTS=false" >> $GITHUB_OUTPUT
fi

- name: Set Git committer identity
- name: Create and push tag
if: steps.version.outputs.TAG_EXISTS == 'false'
run: |
git config --global user.email "p_srivastav@outlook.com"
git config --global user.name "Prashant Srivastav"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "${{ steps.version.outputs.TAG_NAME }}" -m "Release ${{ steps.version.outputs.TAG_NAME }}"
git push origin "${{ steps.version.outputs.TAG_NAME }}"

- name: Tag the release
id: tag
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
NEW_TAG=$(date +'%Y%m%d%H%M%S')
git tag -a "v${NEW_TAG}" -m "Release version ${NEW_TAG}"
git push origin "v${NEW_TAG}"
echo "# Release ${{ steps.version.outputs.TAG_NAME }}" > release-notes.md
echo "" >> release-notes.md
echo "## Changes" >> release-notes.md
echo "- Automated release from commit $(git rev-parse --short HEAD)" >> release-notes.md
gh release create "${{ steps.version.outputs.TAG_NAME }}" \
--title "Release ${{ steps.version.outputs.TAG_NAME }}" \
--notes-file release-notes.md