Skip to content

Commit

Permalink
Update CI to publish only when integration tests has passed (#26)
Browse files Browse the repository at this point in the history
* Update CI to publish only when integration tests has passed

* Remove the Update Changelog step from publish pipeline

Co-authored-by: Denis Tokarev <github@devlato.com>
  • Loading branch information
github-actions[bot] and devlato committed Nov 26, 2021
1 parent 668b957 commit 8b06c25
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 18 deletions.
63 changes: 59 additions & 4 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,65 @@ jobs:
- name: Checkout
uses: actions/checkout@v2.4.0
with:
persist-credentials: false
fetch-depth: 0
- name: Generate changelog
- name: Generate new changelog
run: |
initial_commit=$( git log --reverse --format='%H' | head -n 1 )
printf '\n\ninitial_commit=%s\n\n' "${initial_commit[@]}"
output=''
for tag in $( git tag -l ); do
printf 'Processing tag=%s\n' "${tag[@]}"
commits=$( git log --reverse --format='* (%h) %s (%an)' "${initial_commit}".."${tag}" )
if [ ${#commits[@]} -eq 0 ]; then
commits=$( git log --reverse --format='* (%h) %s (%an)' | head -n 1 )
fi
printf 'commits=<<<COMMITS\n%s\nCOMMITS\n' "${commits[@]}"
section=$( printf '%s\n%s' "## v${tag}" "${commits}" )
initial_commit="${tag}"
step_output=$( printf '%s\n\n' "${section}" )
printf 'version_changelog=<<<CHUNK\n%s\nCHUNK\n\n' "${step_output[@]}"
output=$( printf '%s\n\n' "${step_output}" "${output}" )
done
package_version=$( cat package.json | grep "version" | grep -oE '[0-9.]+' )
last_tag=$( git tag -l | tail -n 1 )
printf 'package_version=%s\nlast_tag=%s\n' "${package_version[@]}" "${last_tag[@]}"
if [ "${package_version}" != "${last_tag}" ]; then
commits=$( git log --reverse --format='* (%h) %s (%an)' "${last_tag}"..HEAD )
if [ ${#commits[@]} -ne 0 ]; then
section=$( printf '%s\n%s' "## v${package_version}" "${commits}" )
output=$( printf '%s\n\n' "${section}" "${output}" )
fi
fi
printf 'Changelog=<<<CHANGELOG\n%s\nCHANGELOG\n\n' "${output[@]}"
printf '%s\n' "${output}" > CHANGELOG.md
- name: Upload new changelog
uses: actions/upload-artifact@v2.2.4
with:
name: changelog
path: CHANGELOG.md
- name: Commit and push the new changelog
run: |
if [ -z $(git status -uno --porcelain) ]; then
printf 'Changelogs are idential, nothing to commit\n'
else
printf 'Committing the updated changelog\n'
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add CHANGELOG.md
git commit -am "Update the project changelog"
fi
- name: Push changes
uses: ad-m/github-push-action@v0.6.0
with:
github_token: '${{ secrets.GITHUB_TOKEN }}'
branch: '${{ github.ref }}'
- name: Generate the changelog for this pull request
id: generate-changelog
run: |
CURRENT_BRANCH="${GITHUB_SHA}"
Expand Down Expand Up @@ -47,9 +104,7 @@ jobs:
pr_milestone: '${{ secrets.NEW_PR_DEFAULT_MILESTONE }}'
github_token: '${{ secrets.GITHUB_TOKEN }}'
- name: Update pull request
# TODO kt3k/update-pr-description@v1.0.4 when it's released
# https://github.com/kt3k/update-pr-description/pull/7
uses: devlato/update-pr-description@patch-3
uses: kt3k/update-pr-description@v1.0.4
with:
pr_title: '${{ env.PR_TITLE }}'
pr_body: '${{ env.PR_DESCRIPTION }}'
Expand Down
15 changes: 1 addition & 14 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
GITHUB_PAT: '${{ secrets.GH_PAT }}'
publish:
needs: [lint, test, build_code, build_docs]
needs: [lint, test, build_code, build_docs, integration_tests]
name: Publish to npm
runs-on: ubuntu-latest
steps:
Expand All @@ -125,16 +125,3 @@ jobs:
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
NPM_TOKEN: '${{ secrets.NPM_AUTH_TOKEN }}'
update_changelog:
needs: [publish]
name: Update changelog
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.4.0
with:
fetch-depth: 0
- name: Generate changelog
uses: ahmadawais/action-auto-changelog@1.0.0
with:
github_token: '${{ secrets.GITHUB_TOKEN }}'
119 changes: 119 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
## v2.0.9
* (a999686) Upgrade all deps and prepare v2.0.9 (Denis Tokarev)
* (7763e70) Update scripts (Denis Tokarev)
* (d151065) Fix (Denis Tokarev)
* (87d3f35) Update codeclimate config (Denis Tokarev)
* (208bd20) Update codeclimate config (Denis Tokarev)
* (71f8658) Update the CI configuration to properly set PR bodies (Denis Tokarev)
* (154f35e) Set test timeout to 10s (Denis Tokarev)
* (d47ce0c) Update auto-labeling (Denis Tokarev)
* (8641a51) Add re-labeling (Denis Tokarev)
* (4d3d2cc) Auto-release and auto-publish daily when possible (#24) (github-actions[bot])

## v2.0.8
* (2a51437) Fix timeout default value in README (#20) (Simon Smith)
* (7c72d54) Upgrade automerge action (Denis Tokarev)
* (5b1fa8f) Fix workflows (Denis Tokarev)
* (ef0219c) GH_PAT -> GITHUB_TOKEN (Denis Tokarev)
* (7e7178d) Adjust spelling in readme and index (#21) (Lukasz Kokot)

## v2.0.7
* (43d46df) Update README (#18) (github-actions[bot])
* (dbf7cdf) Aaa (Denis Tokarev)

## v2.0.6
* (2ef43fa) Fix #16: add 'module' to package.json, manually fix dependabot alerts (#17) (github-actions[bot])

## v2.0.5
* (bfea826) Fix #14 (Denis Tokarev)
* (f6397ea) Increase allowed complexity (Denis Tokarev)

## v2.0.4
* (16cbe84) Update README -> 2.0.4 (#12) (github-actions[bot])
* (0ae085e) Disable secret scan (#13) (github-actions[bot])

## v2.0.3
* (a1cc16f) Further get rid of global variables (Denis Tokarev)
* (38ebf94) Further get rid of global variables (#11) (Denis Tokarev)

## v2.0.2
* (8aa1f79) Fix issue w/wrong setTimeout call (#10) (github-actions[bot])

## v2.0.1
* (b03c05c) Set theme jekyll-theme-slate (Denis Tokarev)
* (c1219a4) Delete index.md (Denis Tokarev)
* (f33d9b1) Delete docs directory (Denis Tokarev)
* (742d063) Fix accidental index.d.ts file removal (#8) (github-actions[bot])

## v2.0.0
* (960d93a) Early 2.0 (#5) (github-actions[bot])

## v1.2.6
* (f860c6e) Update .travis.yml (Denis Tokarev)
* (05c3a74) Update README.md (Denis Tokarev)
* (a7dc1e7) Update .travis.yml (Denis Tokarev)
* (5d801b2) Update package.json (Denis Tokarev)
* (06d2ce2) Set 1.2.6 (Denis Tokarev)

## v1.2.5
* (2ec477c) Update README.md (Denis Tokarev)
* (1cf89a3) Update README.md (Denis Tokarev)
* (37eda17) Update README.md (Denis Tokarev)
* (34f0703) Update README.md (Denis Tokarev)
* (2250371) Update index.d.ts (Denis Tokarev)

## v1.2.4
* (f062270) Update Readme (Denis Tokarev)

## v1.2.3
* (c4bf260) Update token (Denis Tokarev)

## v1.2.2
* (001a0d6) Add Node 10 (Denis Tokarev)

## v1.2.1
* (db8db68) Fix codeclimate config (Denis Tokarev)

## v1.2.0
* (8ea2d41) Add TypeScript definitions (Denis Tokarev)

## v1.1.7
* (83f880c) Update token (Denis Tokarev)

## v1.1.6
* (18de9d6) Remove Bluebird (Denis Tokarev)
* (652a576) Release 1.1.6 (Denis Tokarev)

## v1.1.5
* (e5b0cc3) [*] Update README (devlato)

## v1.1.4
* (44cac7e) [*] Fix codeclimate config (devlato)
* (28763d6) [*] Fix codeclimate config (devlato)
* (7190d49) [+] Add Issues Badge (devlato)

## v1.1.3
* (8ea78c5) [*] Download rank (devlato)

## v1.1.2
* (8a2b2bb) [*] Update README, exclude files from shipping (devlato)
* (d9df56e) [*] Travis CI Integration (devlato)
* (219752f) [*] Ignore travis file for building (devlato)
* (bf113e2) [*] Better CI & CD Integration (devlato)
* (b63b926) [*] Fix code climate (devlato)
* (15c740e) [*] Fix (devlato)
* (23a2b13) [*] Rating support (devlato)

## v1.1.0
* (b63e0e9) [*] Add support for predicate rvalue (devlato)

## v1.0.3
* (1dd0165) [*] Integrate Husky (devlato)

## v1.0.2
* (c0ab7df) [*] Update README (devlato)

## v1.0.1
* (95c3bab) [*] Fix package name (devlato)

## v1.0.0

0 comments on commit 8b06c25

Please sign in to comment.