Skip to content

Commit

Permalink
Merge pull request #130 from datalad/gh-127
Browse files Browse the repository at this point in the history
Set up releasing workflows
  • Loading branch information
yarikoptic authored Mar 19, 2024
2 parents 2fd464f + 3d877f1 commit df06919
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 11 deletions.
29 changes: 29 additions & 0 deletions .datalad-release-action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
fragment-directory: changelog.d

categories:
- name: πŸ’₯ Breaking Changes
bump: major
label: semver-major
- name: πŸš€ Enhancements and New Features
bump: minor
label: semver-minor
- name: πŸ› Bug Fixes
label: semver-patch
- name: πŸ”© Dependencies
label: semver-dependencies
- name: πŸ“ Documentation
label: semver-documentation
- name: 🏠 Internal
label: semver-internal
- name: 🏎 Performance
label: semver-performance
- name: πŸ§ͺ Tests
label: semver-tests

extra-labels:
- name: release
color: 007f70
description: Create a release when this PR is merged
- name: CHANGELOG-missing
color: 5b0406
description: PR does not contain a changelog item yet
34 changes: 34 additions & 0 deletions .github/workflows/add-changelog-snippet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Add changelog.d snippet

on:
# This action should be run in workflows triggered by `pull_request_target`
# (not by regular `pull_request`!)
pull_request_target:
# Run whenever the PR is pushed to, receives a label, or is created with
# one or more labels:
types: [synchronize, labeled]

# Prevent the workflow from running multiple jobs at once when a PR is created
# with multiple labels:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.head.label }}
cancel-in-progress: true

jobs:
add:
runs-on: ubuntu-latest
# Only run on PRs that have the "CHANGELOG-missing" label:
if: contains(github.event.pull_request.labels.*.name, 'CHANGELOG-missing')
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
token: ${{ secrets.RELEASER_GITHUB_TOKEN }}

- name: Add changelog snippet
uses: datalad/release-action/add-changelog-snippet@v1
with:
token: ${{ secrets.RELEASER_GITHUB_TOKEN }}
rm-labels: CHANGELOG-missing
36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Auto-release on PR merge

on:
# This action should be run in workflows triggered by `pull_request_target`
# (not by regular `pull_request`!)
pull_request_target:
branches:
# Create a release whenever a PR is merged into one of these branches:
- master
types:
- closed
# Allow manually triggering a release via a "Run workflow" button on the
# workflow's page:
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
# Only run for manual runs or merged PRs with the "release" label:
if: >
github.event_name == 'workflow_dispatch'
|| (github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release'))
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
token: ${{ secrets.RELEASER_GITHUB_TOKEN }}
# Check out all history so that the previous release tag can be
# found:
fetch-depth: 0

- name: Prepare release
uses: datalad/release-action/release@v1
with:
token: ${{ secrets.RELEASER_GITHUB_TOKEN }}
pypi-token: ${{ secrets.PYPI_TOKEN }}
11 changes: 0 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
____ _ _ _
| _ \ __ _ | |_ __ _ | | __ _ __| |
| | | | / _` | | __| / _` | | | / _` | / _` |
| |_| | | (_| | | |_ | (_| | | |___ | (_| | | (_| |
|____/ \__,_| \__| \__,_| |_____| \__,_| \__,_|
Neuroimaging

This is a high level and scarce summary of the changes between releases. We
would recommend to consult log of the [DataLad git
repository](http://github.com/datalad/datalad-neuroimaging) for more details.

## 0.3.4 (Oct 24, 2023) -- Make BIDS great again

- BIDS metadata extractor(s): do not require `participants.tsv` file to be present
Expand Down
3 changes: 3 additions & 0 deletions changelog.d/pr-130.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### 🏠 Internal

- Set up releasing workflows. Fixes [#127](https://github.com/datalad/datalad-neuroimaging/issues/127) via [PR #130](https://github.com/datalad/datalad-neuroimaging/pull/130) (by [@jwodder](https://github.com/jwodder))
8 changes: 8 additions & 0 deletions changelog.d/scriv.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[scriv]
fragment_directory = changelog.d
entry_title_template = file: templates/entry_title.md.j2
new_fragment_template = file: templates/new_fragment.md.j2
format = md
# The categories must align with the category names in
# .datalad-release-action.yaml
categories = πŸ’₯ Breaking Changes, πŸš€ Enhancements and New Features, πŸ› Bug Fixes, πŸ”© Dependencies, πŸ“ Documentation, 🏠 Internal, 🏎 Performance, πŸ§ͺ Tests
1 change: 1 addition & 0 deletions changelog.d/templates/entry_title.md.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ version if version else "VERSION" }} ({{ date.strftime('%Y-%m-%d') }})
11 changes: 11 additions & 0 deletions changelog.d/templates/new_fragment.md.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Uncomment the section that is right (remove the HTML comment wrapper).-->
{% for cat in config.categories -%}
<!--
### {{ cat }}
- Describe change, possibly reference closed/related issue/PR.
Fixes [#XXX](https://github.com/datalad/datalad-neuroimaging/issues/XXX) via
[PR #YYY](https://github.com/datalad/datalad-neuroimaging/pull/YYY)
(by [@GITHUBHANDLE](https://github.com/GITHUBHANDLE))
-->
{% endfor -%}

0 comments on commit df06919

Please sign in to comment.