Workflow file for this run
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: Publish React-UI Pre-release to npm | |
on: | |
push: | |
branches: | |
- "release/v*" | |
jobs: | |
publish-pre-release: | |
runs-on: ubuntu-latest | |
concurrency: | |
group: "publish-pre-release" | |
cancel-in-progress: false | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Fetch main branch | |
run: git fetch origin main:main | |
shell: bash | |
# - name: Check for merge commits | |
# id: check | |
# run: | | |
# echo "Checking for merge commits since branching from main..." | |
# # Find the commit where the current branch diverged from main | |
# DIVERGE_POINT=$(git merge-base main HEAD) | |
# # Get the merge commits since that point, excluding certain patterns (Merge branch, Merge pull request) | |
# MERGE_COMMITS=$(git log --merges $DIVERGE_POINT..HEAD --pretty=format:"%h %s" | grep -v -E 'Merge branch .* into .*|Merge pull request .* from .*') | |
# echo "Merge commits:" | |
# echo "$MERGE_COMMITS" | |
# # Write the merge commits to commit_messages.txt in bullet point format | |
# COMMIT_MESSAGES=$(git log --merges $DIVERGE_POINT..HEAD --pretty=format:"* %h %s" | grep -v -E 'Merge branch .* into .*|Merge pull request .* from .*') | |
# echo "$COMMIT_MESSAGES" > commit_messages.txt | |
# # Count the merge commits, excluding empty lines | |
# MERGE_COMMIT_COUNT=$(echo "$MERGE_COMMITS" | grep -v '^$' | wc -l) | |
# if [ "$MERGE_COMMIT_COUNT" -eq "0" ]; then | |
# echo "No new merge commits found. Cancelling workflow." | |
# echo "cancel=true" >> $GITHUB_OUTPUT | |
# else | |
# echo "cancel=false" >> $GITHUB_OUTPUT | |
# echo "merge_commits=$MERGE_COMMITS" >> $GITHUB_OUTPUT | |
# fi | |
# shell: bash | |
# - name: Cancel workflow if no merge commits | |
# uses: andymckay/[email protected] | |
# if: steps.check.outputs.cancel == 'true' | |
- name: Install pnpm | |
uses: pnpm/action-setup@v3 | |
with: | |
version: 8 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 'lts/*' | |
cache: 'pnpm' | |
registry-url: 'https://registry.npmjs.org' | |
always-auth: true | |
- name: Install Dependencies | |
run: pnpm install --frozen-lockfile | |
# - name: Run Tests | |
# run: | | |
# 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: Publish to npm | |
shell: bash | |
run: pnpm publish --access=public --tag=ci-test --no-git-checks | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- 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: Fetch latest changes and tags | |
run: git fetch | |
- name: Push Changes and Tags | |
run: | | |
git push | |
git push --tags | |
# - name: Generate Release Notes from Merge Commit Messages | |
# run: | | |
# echo "Generating release notes based on merge commits..." | |
# echo "${{ steps.check.outputs.merge_commits }}" > merge_commits.txt | |
# - 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 | |
- 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. [View Release](https://github.com/IPG-Automotive-UK/react-ui/releases/tag/v${{ env.VERSION }})" | |
}' $TEAMS_WEBHOOK_URL |