Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Bump Version on Release Label

on:
pull_request:
types: [labeled]
branches:
- master

permissions:
contents: write
pull-requests: write

jobs:
bump-version:
# Run only when a release label is added to an open PR
if: |
github.event.pull_request.state == 'open' && (
github.event.label.name == 'release:major' ||
github.event.label.name == 'release:minor' ||
github.event.label.name == 'release:patch'
)
runs-on: ubuntu-latest

steps:
- name: Check out PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install tools
run: |
pip install bump-my-version pandoc
sudo apt-get update
sudo apt-get install -y pandoc
cargo install git-cliff

- name: Set up Git user
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"

- name: Determine version bump type
id: bump
run: |
if [[ "${{ github.event.label.name }}" == "release:major" ]]; then
echo "type=major" >> $GITHUB_OUTPUT
elif [[ "${{ github.event.label.name }}" == "release:minor" ]]; then
echo "type=minor" >> $GITHUB_OUTPUT
else
echo "type=patch" >> $GITHUB_OUTPUT
fi

- name: Bump version
run: bump-my-version bump ${{ steps.bump.outputs.type }}
env:
BMV_ALLOW_DIRTY: "true"

- name: Extract version
id: version
run: |
VERSION=$(bump-my-version show current)
echo "Extracted version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT

- name: Generate changelog
run: |
git cliff --unreleased --tag v${{ steps.version.outputs.version }} -o CHANGELOG.md
echo "Generated changelog for version ${{ steps.version.outputs.version }}"

- name: Update HISTORY.rst
run: |
# Convert CHANGELOG.md to rst and prepend to HISTORY.rst
if [ -f CHANGELOG.md ]; then
pandoc CHANGELOG.md -f markdown -t rst -o CHANGELOG.rst
# Prepend new changelog to HISTORY.rst
if [ -f HISTORY.rst ]; then
cat CHANGELOG.rst HISTORY.rst > HISTORY_temp.rst
mv HISTORY_temp.rst HISTORY.rst
echo "Updated HISTORY.rst with version ${{ steps.version.outputs.version }}"
else
mv CHANGELOG.rst HISTORY.rst
echo "Created HISTORY.rst"
fi
fi

- name: Commit and push changes to PR branch
run: |
git add .
git commit -m "chore: bump version to ${{ steps.version.outputs.version }} and update changelog [skip ci]" || echo "No changes to commit"
git push origin HEAD:${{ github.head_ref }}

- name: Add comment to PR
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '🚀 Version bumped to **v${{ steps.version.outputs.version }}** and changelog updated. Ready to merge!'
})
97 changes: 5 additions & 92 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,104 +1,17 @@
name: Publish on PR merge
name: Publish to PyPI

on:
pull_request:
types: [opened, synchronize, reopened, labeled, closed]
types: [closed]
branches:
- master

permissions:
contents: write
id-token: write
pull-requests: write

jobs:
update-version-and-changelog:
# Run only when a release label is added (not on every push)
if: |
github.event.action == 'labeled' &&
github.event.pull_request.merged == false && (
contains(github.event.pull_request.labels.*.name, 'release:major') ||
contains(github.event.pull_request.labels.*.name, 'release:minor') ||
contains(github.event.pull_request.labels.*.name, 'release:patch')
)
runs-on: ubuntu-latest

steps:
- name: Check out PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install tools
run: |
pip install bump-my-version build pandoc
sudo apt-get update
sudo apt-get install -y pandoc
cargo install git-cliff

- name: Set up Git user
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"

- name: Determine version bump type
id: bump
run: |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'release:major') }}" == "true" ]]; then
echo "type=major" >> $GITHUB_OUTPUT
elif [[ "${{ contains(github.event.pull_request.labels.*.name, 'release:minor') }}" == "true" ]]; then
echo "type=minor" >> $GITHUB_OUTPUT
else
echo "type=patch" >> $GITHUB_OUTPUT
fi

- name: Bump version
run: bump-my-version bump ${{ steps.bump.outputs.type }}
env:
BMV_ALLOW_DIRTY: "true"

- name: Extract version
id: version
run: |
VERSION=$(bump-my-version show current)
echo "Extracted version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT

- name: Generate changelog
run: |
git cliff -o CHANGELOG.md
echo "Generated changelog for version ${{ steps.version.outputs.version }}"

- name: Update HISTORY.rst
run: |
# Convert CHANGELOG.md to rst and prepend to HISTORY.rst
if [ -f CHANGELOG.md ]; then
pandoc CHANGELOG.md -f markdown -t rst -o CHANGELOG.rst
# Prepend new changelog to HISTORY.rst
if [ -f HISTORY.rst ]; then
cat HISTORY.rst CHANGELOG.rst > HISTORY_temp.rst
mv HISTORY_temp.rst HISTORY.rst
echo "Updated HISTORY.rst with version ${{ steps.version.outputs.version }}"
else
mv CHANGELOG.rst HISTORY.rst
echo "Created HISTORY.rst"
fi
fi

- name: Commit and push changes to PR branch
run: |
git add .
git commit -m "chore: bump version to ${{ steps.version.outputs.version }} and update changelog [skip ci]" || echo "No changes to commit"
git push origin HEAD:${{ github.head_ref }}

publish-after-merge:
publish:
# Run only after PR is merged with release labels
if: |
github.event.pull_request.merged == true && (
Expand All @@ -125,7 +38,7 @@ jobs:
- name: Extract version
id: version
run: |
VERSION=$(bump-my-version show current)
VERSION=$(bump-my-version show current_version)
echo "version=$VERSION" >> $GITHUB_OUTPUT

- name: Create GitHub Release
Expand All @@ -146,7 +59,7 @@ jobs:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
attestations: false

- name: Publish to PyPI
if: steps.test-pypi.outcome == 'success'
uses: pypa/gh-action-pypi-publish@v1.13.0
Expand Down
25 changes: 16 additions & 9 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
[changelog]
header = """# Changelog
header = """
# Changelog

All notable changes to this project will be documented in this file.
"""

body = """
{% for group, commits in commits | group_by(attribute="group") %}
## {{ group | upper_first }}
{% for commit in commits %}
- {% if commit.breaking %}[**BREAKING**] {% endif %}{{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}]({{ commit.id }}))
{% endfor %}
## {{ group | upper_first }}
{% for commit in commits %}
- {% if commit.breaking %}[**BREAKING**] {% endif %}{{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}](https://github.com/kujaku11/mth5/commit/{{ commit.id }}))
{% endfor %}

{% endfor %}
"""

Expand All @@ -26,11 +28,16 @@ commit_parsers = [
{ message = "^refactor", group = "Refactor" },
{ message = "^style", group = "Styling" },
{ message = "^test", group = "Testing" },
{ message = "^chore\\(release\\): prepare for", skip = true },
{ message = "^chore\\(deps\\)", skip = true },
{ message = "^chore\\(pr\\)", skip = true },
{ message = "^chore\\(pull\\)", skip = true },
{ message = "^chore(release): prepare for", skip = true },
{ message = "^chore(deps)", skip = true },
{ message = "^chore(pr)", skip = true },
{ message = "^chore(pull)", skip = true },
{ message = "^chore|^ci", skip = true },
{ message = "^chore", group = "Miscellaneous Tasks" },
{ body = ".*security", group = "Security" },
{ message = "^revert", group = "Revert" },
]

# Skip commits that only bump versions
filter_commits = true
skip_tags = "v0.1.0-beta.1"
2 changes: 1 addition & 1 deletion docs/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ dependencies:
- ipython
- jupyter_client
- nbsphinx
- setuptools<=70
- obspy
- setuptools
- sphinx>=2.3
- sphinx_rtd_theme>=0.4
- sphinx-autoapi
Expand Down
85 changes: 85 additions & 0 deletions docs/examples/notebooks/new_documentation.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "3832cec5",
"metadata": {},
"source": [
"# MTH5: Add documentation\n",
"\n",
"This documentation is for a quick start and put stuff in all the same place.\n",
"\n",
"## Phoenix\n",
"\n",
"- Sensor calibration: if a dict is input the values should be validated to be PhoenixCalibration object, if a path is given then it should create a object. \n",
"- Change to have no calibration files. \n",
"- station_group.run_summary doesn't work.\n",
"- Filters are not being extracted to HDF5\n",
"- HDF5 tools don't always work, create some tests to run HDF5 tools\n",
"- Start time in older data should come from the file not the metadata file.\n",
"\n",
"### MTU\n",
"\n",
"- Doesn't know TS2, need to add.\n",
"- Seems like the files for bursts are being overwritten. \n",
"\n",
"## Geomagnetic Observatory data\n",
"\n",
"- Add intermagnetic to clients\n",
"- world data center for geomagnetism\n",
"\n",
"## Metronix \n",
"\n",
"- Add a .ats reader. There id documentation on Metronix website. Check Resistics and Razorback\n",
"\n",
"## Channel Summary\n",
"\n",
"- Add column for sensor.id, sensor.manufacturer, data_logger.id, data_logger.manufacturer\n",
"\n",
"## Metadata\n",
"\n",
"- station id allow for \"-\" in name.\n",
"\n",
"## Documentation\n",
"\n",
"- Add documentation of MakeMTH5\n",
"\n",
"## LEMI\n",
"\n",
"- Need ability to input dipole length. True dipole length and instrument dipole length. \n",
"- put this in the collection and add kwargs as e1, e2, e3, e4.\n",
"\n",
"## IO Repository\n",
"\n",
"- Add a repository for file readers IO that has Matlab, C++, Python readers\n",
"\n",
"## Organization GitHub\n",
"\n",
"- Add documentation how-to document\n",
"- Test data: how-to add data\n",
"- Readme: add how-to contribute\n",
"\n",
"# Release Date\n",
"\n",
"- Mid-June\n",
"\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"id": "d84fbc4f",
"metadata": {},
"source": []
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading
Loading