Skip to content

Merge pull request #6 from sebastian-meckovski/final-pipeline-fix #22

Merge pull request #6 from sebastian-meckovski/final-pipeline-fix

Merge pull request #6 from sebastian-meckovski/final-pipeline-fix #22

name: Version Bump
on:
push:
branches:
- master
jobs:
version_bump:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && !contains(github.event.head_commit.message, 'AUTOMATIC VERSION BUMP')
container:
image: node:18-buster
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install dependencies
run: |
npm i [email protected]
apt-get update -qy
apt-get install -y jq
- name: Bump version
run: |
git config --global --add safe.directory '*'
npm version patch --git-tag-version false
PACKAGE_JSON_FILE=$(cat package.json)
PACKAGE_VERSION=$(echo "$PACKAGE_JSON_FILE" | jq -r '.version')
VAR_TIME=$(date '+%Y-%m-%d')
API_RESPONSE=$(curl --request GET "https://api.github.com/repos/sebastian-meckovski/Seb-Storybook/pulls?state=closed" --header "PRIVATE-TOKEN: ${{ secrets.AUTO_VERSION_TOKEN }}")
FIRST_MERGE_REQUEST=$(echo "$API_RESPONSE" | jq -r '.[0]')
DESCRIPTION=$(echo "$FIRST_MERGE_REQUEST" | jq -r '.body')
AUTHOR=$(echo "$FIRST_MERGE_REQUEST" | jq -r '.user.login')
PR_URL=$(echo "$FIRST_MERGE_REQUEST" | jq -r '.html_url')
TITLE=$(echo "$FIRST_MERGE_REQUEST" | jq -r '.title')
# Add version, description, author, PR URL, and title to CHANGELOG.md
sed -i "2i ## ${PACKAGE_VERSION} (${VAR_TIME})\n- Description: ${DESCRIPTION}\n- Author: ${AUTHOR}\n- Pull request URL: ${PR_URL}\n- Title: ${TITLE}\n" CHANGELOG.md
- name: Configure Git
run: |
git config user.email "[email protected]"
git config user.name "Sebastian Meckovski"
git remote add github-origin https://sebastian-meckovski:${{ secrets.AUTO_VERSION_TOKEN }}@github.com/sebastian-meckovski/Seb-Storybook.git
- name: Commit and push changes
run: |
git add .
git commit -m "AUTOMATIC VERSION BUMP"
git push github-origin HEAD:master
- name: Publish to npm
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
npm run build
npm publish