Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix release workflows to disconnect from pypi #4

Merged
merged 16 commits into from
Mar 18, 2024
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
123 changes: 123 additions & 0 deletions .github/workflows/cd_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: CD - Publish

on:
release:
types:
- published

env:
PUBLISH_UPDATE_BRANCH: master
GIT_USER_NAME: "TEAM 4.0[bot]"
GIT_USER_EMAIL: "[email protected]"


jobs:

update-and-publish:
name: Update CHANGELOG and version and publish to PyPI
runs-on: ubuntu-latest
if: github.repository == 'SINTEF/oteapi-dlite-Mod' && startsWith(github.ref, 'refs/tags/v')

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: Install Python dependencies
run: |
python -m pip install -U pip
pip install -U setuptools wheel build
pip install -U -e .[dev]

- name: Update changelog
uses: CharMixer/auto-changelog-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
release_branch: ${{ env.PUBLISH_UPDATE_BRANCH }}

- name: Set up git user
run: |
git config --global user.name "${GIT_USER_NAME}"
git config --global user.email "${GIT_USER_EMAIL}"

- name: Update version and tag
run: |
invoke setver --version="${GITHUB_REF#refs/tags/}"

git add oteapi_dlite/__init__.py CHANGELOG.md
git commit -m "Release ${GITHUB_REF#refs/tags/} - Changelog"

TAG_MSG=.github/utils/release_tag_msg.txt
sed -i "s|TAG_NAME|${GITHUB_REF#refs/tags/}|" "${TAG_MSG}"
git tag -af -F "${TAG_MSG}" ${GITHUB_REF#refs/tags/}

- name: Update '${{ env.PUBLISH_UPDATE_BRANCH }}'
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.RELEASE_PAT }}
branch: ${{ env.PUBLISH_UPDATE_BRANCH }}
sleep: 15
force: true
tags: true
unprotect_reviews: true

- name: Get tagged versions
run: echo "PREVIOUS_VERSION=$(git tag -l --sort -version:refname | sed -n 2p)" >> $GITHUB_ENV

- name: Create release-specific changelog
uses: CharMixer/auto-changelog-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
release_branch: ${{ env.PUBLISH_UPDATE_BRANCH }}
since_tag: "${{ env.PREVIOUS_VERSION }}"
output: "release_changelog.md"

- name: Append changelog to release body
run: |
gh api /repos/${{ github.repository }}/releases/${{ github.event.release.id }} --jq '.body' > release_body.md
cat release_changelog.md >> release_body.md
gh api /repos/${{ github.repository }}/releases/${{ github.event.release.id }} -X PATCH -F body='@release_body.md'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build source distribution
run: python -m build

docs:
name: Deploy release documentation
needs: update-and-publish
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.PUBLISH_UPDATE_BRANCH }}

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

- name: Install Python dependencies
run: |
python -m pip install -U pip
pip install -U setuptools wheel
pip install -U -e .[docs]

- name: Set up git user
run: |
git config --global user.name "${{ env.GIT_USER_NAME }}"
git config --global user.email "${{ env.GIT_USER_EMAIL }}"

- name: Deploy documentation
run: |
mike deploy --push --remote origin --branch gh-pages --update-aliases --config-file mkdocs.yml ${GITHUB_REF#refs/tags/v} stable
mike deploy --push --remote origin --branch gh-pages --update-aliases --config-file mkdocs.yml latest ${{ env.PUBLISH_UPDATE_BRANCH }}
4 changes: 2 additions & 2 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
run: pytest -vvv --cov-report=xml

- name: Upload coverage to Codecov
if: matrix.python-version == 3.9 && github.repository == 'EMMC-ASBL/oteapi-dlite'
if: matrix.python-version == 3.9 && github.repository == 'SINTEF/oteapi-dlite-Mod'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down Expand Up @@ -148,7 +148,7 @@ jobs:
run: pytest -vvv --cov-report=xml

- name: Upload coverage to Codecov
if: matrix.python-version == 3.9 && github.repository == 'EMMC-ASBL/oteapi-dlite'
if: matrix.python-version == 3.9 && github.repository == 'SINTEF/oteapi-dlite-Mod'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ theme:
- navigation.instant
- navigation.top

repo_name: "oteapi-dlite"
repo_url: "https://github.com/EMMC-ASBL/oteapi-dlite"
repo_name: "oteapi-dlite-Mod"
repo_url: "https://github.com/SINTEF/oteapi-dlite-Mod"
edit_uri: ""

extra:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@
] + DOCS

setup(
name="oteapi-dlite",
name="oteapi-dlite-Mod",
version=VERSION,
author=AUTHOR,
author_email=AUTHOR_EMAIL,
url="https://github.com/EMMC-ASBL/oteapi-dlite",
url="https://github.com/SINTEF/oteapi-dlite-Mod",
description="DLite plugin for OTEAPI.",
long_description=(TOP_DIR / "README.md").read_text(encoding="utf8"),
long_description_content_type="text/markdown",
Expand Down
Loading