Skip to content

Merge branch 'release/v8.0.0-2' of https://github.com/IPG-Automotive-… #8

Merge branch 'release/v8.0.0-2' of https://github.com/IPG-Automotive-…

Merge branch 'release/v8.0.0-2' of https://github.com/IPG-Automotive-… #8

Workflow file for this run

name: Publish Pre-release to npm
on:
push:
branches:
- "release/v*"
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org/"
cache: "pnpm" # Enable automatic caching for pnpm
- name: Install pnpm
run: npm install -g pnpm
- name: Install Dependencies
run: pnpm install
- name: Run Tests
run: |
pnpm test
pnpm test:docker
- name: Bump Version
run: |
pnpm version prerelease --no-git-tag-version
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
env:
CI: true
- name: Configure npm for Scoped Packages
run: |
echo "@ipguk:registry=https://registry.npmjs.org/" >> .npmrc
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc
- name: Publish to npm
run: pnpm publish --access=public --tag=next --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Generate Release Notes from Merge Commit Messages
run: |
echo "Generating release notes based on commit messages..."
# Get the last commit
COMMIT_RANGE=$(git rev-parse HEAD~1)..$(git rev-parse HEAD)
COMMIT_MESSAGES=$(git log $COMMIT_RANGE --pretty=format:"* %s")
echo "$COMMIT_MESSAGES" > commit_messages.txt
- name: Commit Version Changes
run: |
git add package.json
git commit -m "Bump version to ${{ env.VERSION }}"
# Create the Git tag with the version from package.json
git tag -a "v${{ env.VERSION }}" -m "Version ${{ env.VERSION }}"
- name: Push Changes and Tags
run: |
git push
git push --tags
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: "v${{ env.VERSION }}"
name: "${{ env.VERSION }}"
body_path: commit_messages.txt
draft: false
prerelease: true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Post Release Message to Teams
env:
TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }}
run: |
curl -H "Content-Type: application/json" -d '{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"themeColor": "0078D7",
"title": "New Pre-release Published",
"text": "A new pre-release version ${{ env.VERSION }} has been published to npm."
}' $TEAMS_WEBHOOK_URL