Skip to content

CI

CI #48

name: CI
on:
workflow_dispatch:
inputs:
tag:
description: 'Release Tag. This is in the form x.y.z'
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
create-release-branch:
name: Creates a release branch and updates the version number
runs-on: ubuntu-latest
env:
CI_COMMIT_AUTHOR: CentML
CI_COMMIT_EMAIL: [email protected]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create release branch
run: |
git checkout -b release/${{ github.event.inputs.tag }}
git fetch
git branch --set-upstream-to=origin/main release/${{ github.event.inputs.tag }}
- name: Update version
run: |
pushd analyzer
bash git_update_version.sh ${{ github.event.inputs.tag }}
popd
- name: Commit updated version number and tag it
run: |
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
git config --global user.email "${{ env.CI_COMMIT_EMAIL }}"
git add .
git commit -am "Release version ${{ github.event.inputs.tag }}"
git push -u origin release/${{ github.event.inputs.tag }}
git tag ${{ github.event.inputs.tag }}
build-release:
runs-on: [self-hosted, cu121]
steps:
- name: Fetch repository
uses: actions/checkout@v3
with:
ref: release/${{ github.event.inputs.tag }}
- name: Build Python3.8 wheel
run: |
./build_scripts/build_wheel.sh python3.8
- name: Build Python3.9 wheel
run: |
./build_scripts/build_wheel.sh python3.9
- name: Build Python3.10 wheel
run: |
./build_scripts/build_wheel.sh python3.10
- name: Build Python3.11 wheel
run: |
./build_scripts/build_wheel.sh python3.11
- uses: actions/upload-artifact@v3
with:
name: ${{ github.event.inputs.tag }}
path: analyzer/dist/*.whl
publish-to-github:
name: Publish to Github
needs:
- build-release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: release/${{ github.event.inputs.tag }}
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ github.event.inputs.tag }}
path: dist
- name: Publish a release
run: |
RELEASE_NOTES="$(git log $(git describe --abbrev=0 --tags --always).. --merges --pretty=format:"%s %b" | cut -f 4,7- -d ' ')"
echo "Autogenerated Release Notes:"
echo "$RELEASE_NOTES"
RELEASE_ARTIFACTS=$(find ./dist -name "*${{ github.event.inputs.tag }}*" -type f | paste -s -d ' ' - )
VERSION_TAG="v${{ github.event.inputs.tag }}"
gh auth login --with-token <<< "${{ secrets.GH_TOKEN }}"
gh release create "$VERSION_TAG" \
--title "$VERSION_TAG" \
--notes "$RELEASE_NOTES" \
--target "$GITHUB_SHA" \
$RELEASE_ARTIFACTS
gh pr create --title "Release $VERSION_TAG" --body "$RELEASE_NOTES"
publish-to-test-pypi:
name: Publish to Test PyPI
needs: build-release
runs-on: ubuntu-latest
environment: Test
concurrency: Test
permissions:
id-token: write
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ github.event.inputs.tag }}
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository_url: https://test.pypi.org/legacy/
publish-to-pypi:
name: Publish to PyPI
needs: publish-to-test-pypi
runs-on: ubuntu-latest
environment: Production
concurrency: Production
permissions:
id-token: write
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ github.event.inputs.tag }}
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository_url: https://upload.pypi.org/legacy/