Skip to content

Merge pull request #7 from sebastian-meckovski/pipeline-fix #23

Merge pull request #7 from sebastian-meckovski/pipeline-fix

Merge pull request #7 from sebastian-meckovski/pipeline-fix #23

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')
echo "$FIRST_MERGE_REQUEST"
echo "$DESCRIPTION"
echo "$AUTHOR"
echo "$PR_URL"
echo "$TITLE"
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
git status
- 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
# AUTHOR=$(echo "$FIRST_MERGE_REQUEST" | jq -r '.user.login')
# TARGET_BRANCH=$(echo "$FIRST_MERGE_REQUEST" | jq -r '.base.ref')
# PR_URL=$(echo "$FIRST_MERGE_REQUEST" | jq -r '.html_url')
# TITLE=$(echo "$FIRST_MERGE_REQUEST" | jq -r '.title')
# sed -i "2i - Author: ${AUTHOR}" CHANGELOG.md
# sed -i "2i - Pull request URL: ${PR_URL}" CHANGELOG.md
# sed -i "2i - Target branch: ${TARGET_BRANCH}" CHANGELOG.md
# sed -i "2i - Title: ${TITLE}" CHANGELOG.md