From bdb0da02a83ca200469ab714a53df61f2f5409c7 Mon Sep 17 00:00:00 2001 From: Yehonal Date: Sat, 19 Feb 2022 19:32:34 +0100 Subject: [PATCH] fix: workflow (#1) --- .github/workflows/test.yml | 7 +++++-- CHANGELOG.md | 9 +++++++++ README.md | 3 +++ action.yml | 22 ++++++++++++++-------- package.json | 4 ++-- 5 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b9f33ae..aba39e2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,13 +11,16 @@ jobs: if: github.event.label.name == 'pr-version-bump' runs-on: [ubuntu-latest] steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.ref }} - name: Test bump action with: - repository: https://github.dev/Drassil/action-package-version-bump + repository: https://github.com/Drassil/action-package-version-bump user_name: 'drassil-git-bot' user_email: 'drassil-git-bot@drassil.org' ref_branch: 'main' use_rebase: true version_args: 'prerelease --preid=rc${{ env.RC_VERSION }}' node_version: ${{ env.NODE_VERSION }} - uses: ../../ \ No newline at end of file + uses: ./ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..35baf40 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +Rev: 1.0.0-rc1.1 +============= + ## Fixes + +* workflow fixed + + + + diff --git a/README.md b/README.md index 82f383a..e89d745 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ # action-package-version-bump Github action to upgrade the package.json version and create a changelog based on PR description that can be triggered in your workflows + + +ver 1.1 diff --git a/action.yml b/action.yml index edd1453..bfe62c1 100644 --- a/action.yml +++ b/action.yml @@ -38,21 +38,27 @@ runs: ref: ${{ github.event.pull_request.head.ref }} fetch-depth: 0 - name: Pull and bump version + shell: bash run: | git remote add main-repo ${{ inputs.repository }} git config --global user.name ${{ inputs.user_name }} git config --global user.email ${{ inputs.user_email }} git config --global pull.rebase ${{ inputs.use_rebase }} - git pull main-repo - npm version ${{ inputs.version_arguments }} - PACKAGE_VERSION=`npm run --silent version` - PREV_CHANGELOG=`git show main-repo/dev:CHANGELOG.md || true` + git pull main-repo ${{ inputs.ref_branch }} + echo "Updating version" + npm version --no-git-tag-version ${{ inputs.version_args }} + PACKAGE_VERSION=`node -e "console.log(require('./package.json').version);"` + echo "Package version: $PACKAGE_VERSION. Getting previous changelog" + PREV_CHANGELOG=`git show main-repo/${{ inputs.ref_branch }}:CHANGELOG.md || true` + echo "Composing new changelog" echo -e "Rev: $PACKAGE_VERSION\n=============\n ${{ github.event.pull_request.body }}\n\n\n" > CHANGELOG.md echo -e "$PREV_CHANGELOG" >> CHANGELOG.md - git add -u - git commit -m "chore: bump version and changelog" + echo "Creating commit and pushing" + git add -A + git commit -m "chore: bump package version to $PACKAGE_VERSION and update changelog" git push --force - using: 'node12' - main: index.js + - name: Run script + shell: bash + run: node index.js diff --git a/package.json b/package.json index f6629c8..675dd8d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "action-package-version-bump", - "version": "1.0.0-rc1.0", + "version": "1.0.0-rc1.1", "description": "Github action to upgrade the package.json version and create a changelog based on PR description that can be triggered in your workflows", "main": "index.js", "scripts": { @@ -13,4 +13,4 @@ "@actions/exec": "^1.1.0", "@actions/github": "^5.0.0" } -} \ No newline at end of file +}