-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is an introduction to pre-release and release wokflows. The pre-release will build the current main branch a upload it into TEST PyPi repo to test out the current build. The release workflow will generate new autils major or minor input based on the release. Then it will do the build and upload it to PyPi. Reference: #21 Signed-off-by: Jan Richter <[email protected]>
- Loading branch information
Showing
2 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Pre-Release | ||
on: workflow_dispatch | ||
|
||
jobs: | ||
|
||
release-test: | ||
name: Pre-Release pipeline | ||
runs-on: ubuntu-latest | ||
container: | ||
image: fedora:34 | ||
|
||
steps: | ||
- name: Generate token | ||
id: generate_token | ||
uses: tibdex/github-app-token@021a2405c7f990db57f5eae5397423dcc554159c | ||
with: | ||
app_id: ${{ secrets.MR_AVOCADO_ID }} | ||
installation_id: ${{ secrets.MR_AVOCADO_INSTALLATION_ID }} | ||
private_key: ${{ secrets.MR_AVOCADO_PRIVATE_KEY }} | ||
- name: install required packages | ||
run: dnf -y install git python3-pip | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Build wheel | ||
run: | | ||
git config --global --add safe.directory "*" | ||
python3 -m pip install build | ||
mkdir PYPI_UPLOAD | ||
python3 -m build -o PYPI_UPLOAD | ||
- name: Save wheel as artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: wheel | ||
path: ${{github.workspace}}/PYPI_UPLOAD/ | ||
retention-days: 3 | ||
|
||
publish-to-test-pypi: | ||
name: Publish Avocado to TestPyPI | ||
needs: | ||
- release-test | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://test.pypi.org/project/autils | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
steps: | ||
- name: Download all the wheels | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: wheel | ||
path: dist/ | ||
- name: Publish avocado to test PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Release | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Release version type' | ||
type: choice | ||
options: | ||
- major | ||
- minor | ||
default: 'major' | ||
workflow_call: | ||
|
||
jobs: | ||
|
||
release: | ||
name: Release pipeline | ||
runs-on: ubuntu-latest | ||
container: | ||
image: fedora:34 | ||
env: | ||
VERSION: ${{ github.event.inputs.version }} | ||
steps: | ||
- name: Generate token | ||
id: generate_token | ||
uses: tibdex/github-app-token@021a2405c7f990db57f5eae5397423dcc554159c | ||
with: | ||
app_id: ${{ secrets.MR_AVOCADO_ID }} | ||
installation_id: ${{ secrets.MR_AVOCADO_INSTALLATION_ID }} | ||
private_key: ${{ secrets.MR_AVOCADO_PRIVATE_KEY }} | ||
- name: install required packages | ||
run: dnf -y install git python3-pip | ||
- uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
fetch-depth: 0 | ||
- name: Commit files and tag | ||
run: | | ||
git config --global --add safe.directory "*" | ||
git config --global user.name mr-avocado | ||
git config --global user.email "[email protected]" | ||
if [[ ${{ env.VERSION }} = "major" ]]; then | ||
version=$(git tag --sort=version:refname | tail -n 1 | awk -F. '{$1++; $2=0; print $1"."$2}') | ||
else | ||
version=$(git tag --sort=version:refname | tail -n 1 | awk -F. '{$1; $2++; print $1"."$2}') | ||
fi | ||
git tag "$version" -m "Release $version" | ||
- name: Push changes to github | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ steps.generate_token.outputs.token }} | ||
branch: ${{ github.ref }} | ||
- name: Build wheel | ||
run: | | ||
python3 -m pip install build | ||
mkdir PYPI_UPLOAD | ||
python3 -m build -o PYPI_UPLOAD | ||
- name: Save wheel as artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: wheel | ||
path: ${{github.workspace}}/PYPI_UPLOAD/ | ||
retention-days: 3 | ||
|
||
publish-to-pypi: | ||
name: Publish Avocado to PyPI | ||
needs: | ||
- release | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/project/autils | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
steps: | ||
- name: Download all the wheels | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: wheel | ||
path: dist/ | ||
- name: Publish avocado to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 |