Build release #125
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
name: Build release | |
on: | |
workflow_dispatch: | |
inputs: | |
release_version: | |
description: 'Version number of the release' | |
required: true | |
jobs: | |
check-preconditions: | |
name: Check if passes all requirements | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
poetry-version: [ 1.5.0 ] | |
os: [ ubuntu-latest ] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.10" | |
- name: Run image | |
uses: abatilo/actions-poetry@v2 | |
with: | |
poetry-version: ${{ matrix.poetry-version }} | |
- name: build esmf-aspect | |
run: | | |
cd core/esmf-aspect-meta-model-python | |
poetry install | |
poetry run download-samm-release | |
poetry build | |
# - name: run tests | |
# run: | | |
# cd core/esmf-aspect-meta-model-python | |
# poetry run tox -e py310 | |
# - name: run code style checks | |
# run: | | |
# cd core/esmf-aspect-meta-model-python | |
# poetry run tox -e pep8 | |
create_and_publish_release: | |
name: Create tagged release | |
needs: [check-preconditions] | |
runs-on: ${{ matrix.os }} | |
permissions: | |
# Give the default GITHUB_TOKEN write permission to commit and push the | |
# added or changed files to the repository. | |
contents: write | |
strategy: | |
fail-fast: false | |
matrix: | |
poetry-version: [ 1.5.0 ] | |
os: [ ubuntu-latest ] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.10" | |
- name: Install poetry ${{ matrix.poetry-version }} | |
run: | | |
python -m ensurepip | |
python -m pip install --upgrade pip | |
python -m pip install poetry==${{ matrix.poetry-version }} | |
- name: Setup Git | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
- name: Get the current version | |
run: | | |
cd core/esmf-aspect-meta-model-python | |
version=$(poetry version -s) | |
echo "current_version=${version}" >> $GITHUB_ENV | |
- name: Check version incrementing | |
if: ${{ !contains( github.event.inputs.release_version, '-M' ) }} | |
run: python -c "assert '${{ github.event.inputs.release_version }}' > '${{ env.current_version }}'" | |
shell: sh | |
- name: Check version format | |
if: ${{ !contains( github.event.inputs.release_version, '-M' ) }} | |
run: | | |
if [[ ${{ github.event.inputs.release_version }} =~ ^[0-9]+.[0-9]+.[0-9]+$ ]]; then | |
echo release version is valid | |
else | |
echo release version ${{ github.event.inputs.release_version }} is invalid | |
exit 1 | |
fi | |
- name: Set versions | |
continue-on-error: true | |
run: | | |
release_version=${{ github.event.inputs.release_version }} | |
release_branch_name=${release_version%.*}.x | |
echo "release_branch_name=$release_branch_name" >> $GITHUB_ENV | |
- name: Prepare release branch | |
continue-on-error: true | |
run: | | |
git fetch | |
git checkout -b ${{ env.release_branch_name }} | |
git push --set-upstream origin ${{ env.release_branch_name }} | |
git status | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.release_branch_name }} | |
- name: Set antora version | |
run: | | |
git status | |
yq eval -i '.version = "${{ github.event.inputs.release_version }}"' documentation/python-sdk-guide/antora.yml | |
- name: Set esmf-aspect project version | |
id: ESMF_version | |
run: | | |
cd core/esmf-aspect-meta-model-python | |
poetry version ${{ github.event.inputs.release_version }} | |
echo "EsmfVersion=${{ github.event.inputs.release_version }}" >> $GITHUB_ENV | |
echo "::set-output name=EsmfVersion::${{ github.event.inputs.release_version }}" | |
- name: Push changes to the release branch | |
run: | | |
git status | |
git add documentation/python-sdk-guide/antora.yml | |
git add core/esmf-aspect-meta-model-python/pyproject.toml | |
git commit -m "Release version ${{steps.ESMF_version.outputs.EsmfVersion}}." | |
git log -n 4 --oneline | |
- name: Create tag | |
run: | | |
git status | |
tag_version=v${{ github.event.inputs.release_version }} | |
git tag $tag_version | |
git push origin $tag_version | |
git log -n 4 --oneline | |
- name: Create changelog | |
id: changelog | |
uses: requarks/changelog-action@v1 | |
with: | |
token: ${{ github.token }} | |
tag: v${{ github.event.inputs.release_version }} | |
includeInvalidCommits: true | |
- name: Create and tag GitHub release | |
uses: softprops/action-gh-release@v1 | |
with: | |
body: ${{ steps.changelog.outputs.changes }} | |
name: "Release version ${{ github.event.inputs.release_version }}" | |
tag_name: v${{ github.event.inputs.release_version }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and publish esmf-aspect-model-loader project | |
run: | | |
git checkout ${{ env.release_branch_name }} | |
git status | |
cd core/esmf-aspect-meta-model-python | |
poetry install | |
poetry run download-samm-release | |
poetry build | |
# poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} | |
# poetry publish |