From 988f8729cb436e40f19181f2b695c6db954721c9 Mon Sep 17 00:00:00 2001 From: "Xuan (Sean) Hu" Date: Thu, 14 Sep 2023 16:33:38 +0800 Subject: [PATCH] ci: Release on tags that matches semantic version. (#161) --- .github/workflows/package.yml | 23 ------- .github/workflows/pages.yml | 37 ----------- .github/workflows/release.yml | 65 +++++++++++++++++++ .vscode/settings.json | 1 + README.md | 3 +- includes/variable.jinja | 3 +- template/.vscode/settings.json | 1 + .../workflows/package.yml.jinja | 23 ------- .../workflows/pages.yml.jinja | 37 ----------- .../workflows/release.yml.jinja | 65 +++++++++++++++++++ 10 files changed, 134 insertions(+), 124 deletions(-) delete mode 100644 .github/workflows/package.yml delete mode 100644 .github/workflows/pages.yml create mode 100644 .github/workflows/release.yml delete mode 100644 template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/package.yml.jinja delete mode 100644 template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/pages.yml.jinja create mode 100644 template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/release.yml.jinja diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml deleted file mode 100644 index 825347c8..00000000 --- a/.github/workflows/package.yml +++ /dev/null @@ -1,23 +0,0 @@ -jobs: - package: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 - with: - cache: pip - python-version: '3.11' - - run: env | sort - - run: make dev-package - - run: make build - - env: - TWINE_NON_INTERACTIVE: true - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - TWINE_USERNAME: ${{ vars.TWINE_USERNAME }} - run: make upload -name: Package -on: - release: - types: - - published diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml deleted file mode 100644 index f74ff7b0..00000000 --- a/.github/workflows/pages.yml +++ /dev/null @@ -1,37 +0,0 @@ -concurrency: - cancel-in-progress: true - group: ${{ github.workflow }}-${{ github.ref }} -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Python - uses: actions/setup-python@v4 - with: - cache: pip - python-version: '3.11' - - run: env | sort - - run: make dev-docs - - run: make docs - - name: Upload pages artifact - uses: actions/upload-pages-artifact@v2 - with: - path: public - deploy: - needs: build - permissions: - pages: write - id-token: write - runs-on: ubuntu-latest - steps: - - id: deployment - name: Deploy to GitHub Pages - uses: actions/deploy-pages@v2 -name: Pages -on: - release: - types: - - published diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..c2c2e151 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,65 @@ +jobs: + package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + cache: pip + python-version: '3.11' + - run: env | sort + - run: make dev-package + - run: make build + - env: + TWINE_NON_INTERACTIVE: true + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + TWINE_USERNAME: ${{ vars.TWINE_USERNAME }} + run: make upload + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install git-changelog using pipx + run: pipx install git-changelog + - name: Prepare release notes + run: git-changelog --release-notes > release-notes.md + - name: Create GitHub release + uses: softprops/action-gh-release@v1 + with: + body_path: release-notes.md + prerelease: ${{ startsWith(github.ref, 'refs/tags/v0') }} + pages-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v4 + with: + cache: pip + python-version: '3.11' + - run: env | sort + - run: make dev-docs + - run: make docs + - name: Upload pages artifact + uses: actions/upload-pages-artifact@v2 + with: + path: public + pages-deploy: + needs: build + permissions: + pages: write + id-token: write + runs-on: ubuntu-latest + steps: + - id: deployment + name: Deploy to GitHub Pages + uses: actions/deploy-pages@v2 +name: Release +on: + push: + tags: + - v[1-9][0-9]*.[0-9]+.[0-9]+ + - v0.[0-9]+.[0-9]+ diff --git a/.vscode/settings.json b/.vscode/settings.json index a03641a6..26c6dbc6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -38,6 +38,7 @@ "pytest", "Quickstart", "setuptools", + "softprops", "toctree", "typer", "unshallow" diff --git a/README.md b/README.md index 50a56ee2..6d0b8074 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,7 @@ A development-focused Python project template with various integrations, configurations and modules. [![CI](https://github.com/serious-scaffold/serious-scaffold-python/actions/workflows/ci.yml/badge.svg)](https://github.com/serious-scaffold/serious-scaffold-python/actions/workflows/ci.yml) -[![Pages](https://github.com/serious-scaffold/serious-scaffold-python/actions/workflows/pages.yml/badge.svg)](https://github.com/serious-scaffold/serious-scaffold-python/actions/workflows/pages.yml) -[![Package](https://github.com/serious-scaffold/serious-scaffold-python/actions/workflows/package.yml/badge.svg)](https://github.com/serious-scaffold/serious-scaffold-python/actions/workflows/package.yml) +[![Release](https://github.com/serious-scaffold/serious-scaffold-python/actions/workflows/release.yml/badge.svg)](https://github.com/serious-scaffold/serious-scaffold-python/actions/workflows/release.yml) [![Coverage](https://img.shields.io/endpoint?url=https://serious-scaffold.github.io/serious-scaffold-python/reports/coverage/coverage_badge.json)](https://serious-scaffold.github.io/serious-scaffold-python/reports/coverage) [![PyPI](https://img.shields.io/pypi/v/serious-scaffold)](https://pypi.org/project/serious-scaffold/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/serious-scaffold)](https://pypi.org/project/serious-scaffold/) diff --git a/includes/variable.jinja b/includes/variable.jinja index d900b6f7..f0f11af7 100644 --- a/includes/variable.jinja +++ b/includes/variable.jinja @@ -38,8 +38,7 @@ [% macro pipeline_badge() -%] [% if repo_host_type == 'github.com' -%] [![CI](https://{{ repo_url() }}/actions/workflows/ci.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/ci.yml) -[![Pages](https://{{ repo_url() }}/actions/workflows/pages.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/pages.yml) -[![Package](https://{{ repo_url() }}/actions/workflows/package.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/package.yml) +[![Release](https://{{ repo_url() }}/actions/workflows/release.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/release.yml) [%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%] [![pipeline status](https://{{ repo_url() }}/badges/main/pipeline.svg)](https://{{ repo_url() }}/-/commits/main) [%- endif %] diff --git a/template/.vscode/settings.json b/template/.vscode/settings.json index a03641a6..26c6dbc6 100644 --- a/template/.vscode/settings.json +++ b/template/.vscode/settings.json @@ -38,6 +38,7 @@ "pytest", "Quickstart", "setuptools", + "softprops", "toctree", "typer", "unshallow" diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/package.yml.jinja b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/package.yml.jinja deleted file mode 100644 index b9278df5..00000000 --- a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/package.yml.jinja +++ /dev/null @@ -1,23 +0,0 @@ -jobs: - package: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 - with: - cache: pip - python-version: '{{ default_py }}' - - run: env | sort - - run: make dev-package - - run: make build - - env: - TWINE_NON_INTERACTIVE: true - TWINE_PASSWORD: {{ '${{ secrets.TWINE_PASSWORD }}' }} - TWINE_USERNAME: {{ '${{ vars.TWINE_USERNAME }}' }} - run: make upload -name: Package -on: - release: - types: - - published diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/pages.yml.jinja b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/pages.yml.jinja deleted file mode 100644 index c9699b38..00000000 --- a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/pages.yml.jinja +++ /dev/null @@ -1,37 +0,0 @@ -concurrency: - cancel-in-progress: true - group: {{ '${{ github.workflow }}-${{ github.ref }}' }} -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Python - uses: actions/setup-python@v4 - with: - cache: pip - python-version: '{{ default_py }}' - - run: env | sort - - run: make dev-docs - - run: make docs - - name: Upload pages artifact - uses: actions/upload-pages-artifact@v2 - with: - path: public - deploy: - needs: build - permissions: - pages: write - id-token: write - runs-on: ubuntu-latest - steps: - - id: deployment - name: Deploy to GitHub Pages - uses: actions/deploy-pages@v2 -name: Pages -on: - release: - types: - - published diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/release.yml.jinja b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/release.yml.jinja new file mode 100644 index 00000000..04f48563 --- /dev/null +++ b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/release.yml.jinja @@ -0,0 +1,65 @@ +jobs: + package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + cache: pip + python-version: '{{ default_py }}' + - run: env | sort + - run: make dev-package + - run: make build + - env: + TWINE_NON_INTERACTIVE: true + TWINE_PASSWORD: {{ '${{ secrets.TWINE_PASSWORD }}' }} + TWINE_USERNAME: {{ '${{ vars.TWINE_USERNAME }}' }} + run: make upload + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install git-changelog using pipx + run: pipx install git-changelog + - name: Prepare release notes + run: git-changelog --release-notes > release-notes.md + - name: Create GitHub release + uses: softprops/action-gh-release@v1 + with: + body_path: release-notes.md + prerelease: {{ '${{ startsWith(github.ref, \'refs/tags/v0\') }}' }} + pages-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v4 + with: + cache: pip + python-version: '3.11' + - run: env | sort + - run: make dev-docs + - run: make docs + - name: Upload pages artifact + uses: actions/upload-pages-artifact@v2 + with: + path: public + pages-deploy: + needs: build + permissions: + pages: write + id-token: write + runs-on: ubuntu-latest + steps: + - id: deployment + name: Deploy to GitHub Pages + uses: actions/deploy-pages@v2 +name: Release +on: + push: + tags: + - v[1-9][0-9]*.[0-9]+.[0-9]+ + - v0.[0-9]+.[0-9]+