Skip to content

Commit

Permalink
chore(actions): automate changelog creation process (#1082)
Browse files Browse the repository at this point in the history
  • Loading branch information
vascoalramos authored Oct 4, 2022
1 parent 42ea65c commit 2b2566c
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 110 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/merge-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,17 @@ jobs:
run: echo "::set-output name=value::${{ steps.semantic.outputs.value }}.pre${{ steps.build_number.outputs.value }}"


prerelease:
name: Generates Prerelease
prerelease-tag:
name: Create Prerelease Tag
runs-on: ubuntu-20.04

needs:
- prepare

steps:
- name: Create Pre Release
uses: softprops/action-gh-release@v1
- uses: simpleactions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
with:
tag_name: ${{ needs.prepare.outputs.version }}
name: ${{ needs.prepare.outputs.version }}
body: ${{ github.event.head_commit.message }}
target_commitish: ${{ github.sha }}
prerelease: true
tag: ${{ needs.prepare.outputs.version }}
message: ${{ github.event.head_commit.message }}
68 changes: 55 additions & 13 deletions .github/workflows/merge-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
outputs:
build_number: ${{ steps.build_number.outputs.value }}
new_release: ${{ steps.semantic.outputs.new_release_published }}
release: ${{ steps.semantic.outputs.new_release_version }}
release: v${{ steps.semantic.outputs.new_release_version }}
release_notes: ${{ steps.semantic.outputs.new_release_notes }}
version: ${{ steps.version.outputs.value }}
version: v${{ steps.version.outputs.value }}

steps:
- uses: actions/checkout@v2
Expand All @@ -31,7 +31,6 @@ jobs:
with:
branch: master
dry_run: true
semantic_version: 18.0.1

- name: Count number or releases for tag
id: build_number
Expand All @@ -41,32 +40,75 @@ jobs:
id: version
run: echo "::set-output name=value::${{ steps.semantic.outputs.new_release_version }}.rc${{ steps.build_number.outputs.value }}"

prerelease:
docs-changelog:
name: Update changelog on docs
runs-on: ubuntu-20.04

needs: prepare

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Calculate changelog path
id: path
run: echo "$(echo "::set-output name=value::docsrc/source/pages/reference/changelog/${{ needs.prepare.outputs.release }}" | sed "s/\./_/g").rst"

- name: Configure Git
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git config --local core.autocrlf false
- name: Convert changelog from md to rst
run: |
sudo apt-get install -y pandoc
echo "${{ needs.prepare.outputs.release_notes }}" \
| sed 's/# \[.*/# Changelog ${{ needs.prepare.outputs.release }}/g' \
| sed 's/## Bug Fixes/## 🐛 Bug fixes/g' \
| sed 's/## Features/## 🎉 Features/g' \
| sed 's/## BREAKING CHANGES/## 🚨 Breaking changes/g' \
| sed 's/## Documentation/## 📖 Documentation/g' \
| pandoc --from markdown --to rst --standalone > ${{ steps.path.outputs.value }}
- name: Commit changelog
run: |
git add ${{ steps.path.outputs.value }}
git commit -m "[skip ci] Update changelogs" -a || true
- name: Push changes
uses: ad-m/[email protected]
with:
branch: ${{ github.ref }}
github_token: ${{ secrets.ACCESS_TOKEN }}

prerelease-tag:
if: needs.prepare.outputs.new_release == 'true'

name: Generates Prerelease
name: Create Prerelease Tag
runs-on: ubuntu-20.04

needs: prepare
needs:
- prepare

steps:
- name: Create Pre Release
uses: actions/create-release@v1
- uses: simpleactions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
with:
tag_name: ${{ needs.prepare.outputs.version }}
release_name: ${{ needs.prepare.outputs.version }}
body: ${{ github.event.head_commit.message }}
prerelease: true
tag: ${{ needs.prepare.outputs.version }}
message: ${{ github.event.head_commit.message }}

draft-release:
if: needs.prepare.outputs.new_release == 'true'

name: Draft Release
runs-on: ubuntu-20.04

needs: prepare
needs:
- prepare
- docs-changelog

steps:
- name: Delete Previous drafts
Expand Down
80 changes: 0 additions & 80 deletions .github/workflows/prerelease.yml

This file was deleted.

18 changes: 12 additions & 6 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
branches:
- master


jobs:
commitlint:
name: Lint commmit message
Expand All @@ -16,7 +15,7 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: wagoid/commitlint-github-action@v3

lint:
Expand Down Expand Up @@ -57,16 +56,23 @@ jobs:
- name: Install the package
run: make install

- name: Code formatting
- name: Validate code formatting
run: make lint

- name: Commit code formatting changes
id: commit
run: |
git add -u
git commit -m "[skip ci] Code formatting" -a || true
if [[ `git status --porcelain --untracked-files=no` ]]; then
echo ::set-output name=CHANGES::true
git add -u
git commit -m "[skip ci] Code formatting" -a
else
echo ::set-output name=CHANGES::false
fi
- name: Push changes
uses: ad-m/[email protected]
if: ${{ steps.commit.outputs.CHANGES == 'true' }}
with:
branch: ${{ github.head_ref }}
github_token: ${{ secrets.GITHUB_TOKEN }}
github_token: ${{ secrets.ACCESS_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,4 @@ jobs:
with:
branch: gh-pages
directory: .
github_token: ${{ secrets.GITHUB_TOKEN }}
github_token: ${{ secrets.ACCESS_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ jobs:
uses: andymckay/labeler@master
with:
add-labels: "needs-triage"
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token: ${{ secrets.ACCESS_TOKEN }}
ignore-if-labeled: true

0 comments on commit 2b2566c

Please sign in to comment.