Skip to content

Commit

Permalink
ci: update ci with reusable workflows and new release flow (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
k4black authored Nov 3, 2023
1 parent 441da05 commit e993edd
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 151 deletions.
86 changes: 1 addition & 85 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,85 +1 @@
name-template: '$RESOLVED_VERSION'
tag-template: '$RESOLVED_VERSION'

change-template: '- $TITLE (#$NUMBER) by @$AUTHOR'


autolabeler:
- label: 'type: feature'
title:
- '/feat:.*/'
- '/feature:.*/'
- label: 'type: fix'
branch:
- '/fix.+/'
- '/bug.+/'
title:
- '/fix:.*/'
- '/bugfix:.*/'
- '/bug:.*/'
- label: 'type: chore'
files:
- '*.md'
- '*.txt'
- label: 'type: docs'
branch:
- '/docs.+/'
title:
- '/docs:.*/'
- label: 'type: refactor'
title:
- '/ref:.*/'
- '/refactor:.*/'
- label: 'type: style'
title:
- '/style:.*/'
- label: 'type: performance'
title:
- '/perf:.*/'
- '/performance:.*/'
- label: 'type: test'
title:
- '/test:.*/'
- '/tests:.*/'
files:
- 'tests/*'
- label: 'type: ci'
title:
- '/ci:.*/'
files:
- '.github/*'


categories:
- title: 'Breaking'
label: 'type: breaking'
- title: 'Features'
label: 'type: feature'
- title: 'Fixes'
label: 'type: fix'
- title: 'Documentation'
label: 'type: docs'
- title: 'CI/CD'
labels:
- 'type: test'
- 'type: ci'
- title: 'Enhancement'
labels:
- 'type: refactor'
- 'type: performance'
- 'type: style'
- title: 'Other changes'

version-resolver:
major:
labels:
- 'type: breaking'
minor:
labels:
- 'type: feature'
default: patch

template: |
$CHANGES
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...$RESOLVED_VERSION
_extends: .github:.github/release-drafter.yml
20 changes: 0 additions & 20 deletions .github/workflows/pr-title.yml

This file was deleted.

53 changes: 17 additions & 36 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,30 @@
name: Publish

# on release created (tag auto created)

on:
release:
types:
- released
# push:
# # Sequence of patterns matched against refs/tags
# tags:
# - '*.*.*' # i.e. 1.0.0, 20.15.10

jobs:

update-version-and-changelog-files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
token: ${{ secrets.MANYTASK_BOT_TOKEN }}
- name: Setup git
run: |
git config --global user.name 'manytask-bot'
git config --global user.email 'manytask-bot@users.noreply.github.com'
- name: Update version file
run: |
echo "Update version to ${{github.ref_name}}"
echo -n "${{github.ref_name}}" > VERSION
- name: Update changelog file
run: |
# TODO: update CHANGELOG.md with release notes
echo "Update CHANGELOG to ${{github.ref_name}}"
- name: Commit updated files
run: |
git add VERSION CHANGELOG.md
git commit -m "chore: auto version and changelog update (${{ github.ref_name }})" -m "[no ci]" || true
git push origin
- name: Tag new commit
run: |
git tag --force ${{ github.ref_name }}
git push origin ${{ github.ref_name }} --force
concurrency:
group: ${{ github.workflow }}-${{ github.event.release.id }}
cancel-in-progress: false


jobs:
update-version-changelog:
uses: manytask/.github/.github/workflows/reusable-update-changelog-version.yml@main
permissions:
contents: write
with:
release_tag: ${{ github.event.release.tag_name }}
release_target: ${{ github.event.release.target_commitish }}
release_body: ${{ github.event.release.body }}
release_url: ${{ github.event.release.html_url }}

release-python-package:
needs: update-version-and-changelog-files
needs: update-version-changelog
runs-on: ubuntu-latest
environment:
name: pypi
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
name: Release Drafter


on:
push:
branches:
- main
# pull_request events is required only for autolabeler
pull_request:
types: [opened, reopened, synchronize]
pull_request_target:
types: [opened, reopened, synchronize]


permissions:
contents: read
contents: write


concurrency:
group: ${{ github.ref }}
cancel-in-progress: true


jobs:
update_release_draft:
permissions:
contents: write # for release-drafter/release-drafter to create a github release
pull-requests: write # for release-drafter/release-drafter to add label to PR
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36 changes: 36 additions & 0 deletions .github/workflows/sync-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Sync PR

on:
pull_request_target:
types:
- opened
- edited
- synchronize
- labeled
- unlabeled
- reopened


concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true


jobs:
autolabel_pr:
permissions:
pull-requests: write
runs-on: ubuntu-latest
if: github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'edited'
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

validate_pr:
needs: [autolabel_pr]
if: ${{ always() && !failure() && !cancelled() }} # no needs jobs are failed or cancelled
uses: manytask/.github/.github/workflows/reusable-validate-pr.yml@main
permissions:
pull-requests: read
contents: read

0 comments on commit e993edd

Please sign in to comment.