Skip to content

Commit

Permalink
Update the release process to use GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
milliams committed Aug 2, 2022
1 parent c50d254 commit cb4a3df
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 137 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-FileCopyrightText: © 2022 Matt Williams <[email protected]>
# SPDX-License-Identifier: MIT

name: Check

on: [push, pull_request, workflow_call]

permissions:
contents: read

jobs:
code-checks:
name: Tests and lints
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- name: Install doxygen
run: |
sudo apt install -y doxygen
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
run: pip install poetry
- name: Setup package
run: poetry install
- name: Run mypy
run: poetry run mypy --install-types --non-interactive sphinxcontrib/doxylink
- name: Run pytest
run: poetry run pytest
- name: Test that package builds
run: poetry build
78 changes: 0 additions & 78 deletions .github/workflows/main.yml

This file was deleted.

95 changes: 95 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# SPDX-FileCopyrightText: © 2022 Matt Williams <[email protected]>
# SPDX-License-Identifier: MIT

name: Release

on:
workflow_dispatch:
inputs:
version:
description: The new version, can be "patch", "minor", "major" (or a valid semver string)
required: true
type: string

permissions: {}

jobs:
run-tests:
uses: ./.github/workflows/check.yml
permissions:
contents: read
make-release:
name: "Release new ${{ inputs.version }} version"
needs: run-tests
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# Set things up
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.*"
- name: Install Poetry
run: python -m pip install poetry

# Update and save the version
- name: update version
run: |
poetry version ${{ inputs.version }}
git add pyproject.toml
- name: Save the version
id: get_version
run: echo ::set-output name=version::"$(poetry version --short)"
- name: Update version in code
run: |
sed --in-place "s/__version__ = \".*\"/__version__ = \"${{ steps.get_version.outputs.version }}\"/" sphinxcontrib/doxylink/__init__.py
git add sphinxcontrib/doxylink/__init__.py
# Update and save the changelog
- name: Install chachacha
run: python -m pip install chachacha
- name: Update changelog version
run: |
head -n 5 CHANGELOG.md > header.tmp
chachacha release "${{ steps.get_version.outputs.version }}"
sed -i '/and this project adheres to/a \\n## [Unreleased]' CHANGELOG.md
cat header.tmp CHANGELOG.md > CHANGELOG.fixed.md
mv CHANGELOG.fixed.md CHANGELOG.md
rm header.tmp
git add CHANGELOG.md
- name: Extract changelog section
run: |
cargo install markdown-extract
changelog=$(markdown-extract --no-print-matched-heading "${{ steps.get_version.outputs.version }}" CHANGELOG.md)
echo "changelog<<EOF" >> $GITHUB_ENV
echo "$changelog" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Commit and tag
run: |
git config --global user.name "Matt Williams"
git config --global user.email "[email protected]"
git commit -m "Release ${{ steps.get_version.outputs.version }}"
git tag "${{ steps.get_version.outputs.version }}"
git push --atomic --tags origin HEAD
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.version }}
release_name: ${{ steps.get_version.outputs.version }}
body: ${{ env.changelog }}
draft: false
# TODO set prerelease based on version passed in
prerelease: false

# Publish release to PyPI
- name: Set PyPI credentials
run: poetry config pypi-token.pypi ${PYPI_TOKEN}
env:
PYPI_TOKEN: ${{ secrets.pypi_token }}
- name: Publish
run: poetry publish --build
10 changes: 10 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Contributing to doxylink
========================

Making releases
---------------

Releases are managed by GitHub Actions.
There is an action called `Release <https://github.com/sphinx-contrib/doxylink/actions/workflows/release.yml>`_ which can be manually triggered.
On that page, you can select "Run workflow" and set the type of release, either "patch", "minor" or "major".
We conform to SemVer so if there have only been bug fixes, use "patch", and if there have been new features use "minor".
59 changes: 0 additions & 59 deletions release.sh

This file was deleted.

0 comments on commit cb4a3df

Please sign in to comment.