Create Release #3
This file contains hidden or 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: Create Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| versionChoice: | |
| type: choice | |
| required: true | |
| description: Version Change | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| permissions: | |
| contents: write | |
| env: | |
| IMAGE_NAME: sae-ai-control | |
| DOCKERHUB_USERNAME: starwit | |
| DOCKERHUB_ORG: starwitorg | |
| jobs: | |
| create-release: | |
| name: create new release | |
| runs-on: [self-hosted, linux, X64] | |
| container: | |
| image: starwitorg/debian-packaging:0.0.3 | |
| volumes: | |
| - /home/githubrunner/.cache/pypoetry:/root/.cache/pypoetry | |
| env: | |
| PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD_FLAT }} | |
| GPG_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY_B64 }} | |
| steps: | |
| #---------------------------------------------- | |
| # check-out repo and set-up python | |
| #---------------------------------------------- | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Install GH CLI | |
| uses: dev-hanz-ops/install-gh-cli-action@v0.2.1 | |
| - name: create new version in pyproject.toml | |
| run: | | |
| poetry version $VERSION | |
| env: | |
| VERSION: ${{ inputs.versionChoice }} | |
| - name: commit new version | |
| run: | | |
| git config --global user.email "code@starwit.de" | |
| git config --global user.name "Starwit" | |
| git remote set-url --push origin https://Starwit:$GITHUB_TOKEN@github.com/starwit/${{ env.IMAGE_NAME }}.git | |
| git add . | |
| modifications=$(git status | grep "modified" || true) | |
| if [ ! -z "$modifications" ] | |
| then | |
| echo "modifications found: $modifications" | |
| git commit -m "modified project version" ./pyproject.toml | |
| git push | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: build apt package | |
| run: | | |
| echo "Build APT package" | |
| bash -c "poetry self add poetry-plugin-export; make build-deb" | |
| echo "Finish building APT package" | |
| - name: Create github release | |
| run: | | |
| APP_VERSION=$(cat pyproject.toml | grep "version" | head -1 | cut -d'=' -f2 | xargs echo -n) | |
| gh release create $APP_VERSION -F README.md --title "${APP_VERSION}" --target $(git branch --show-current) ./target/*deb ./target/*.dsc | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish_docker: | |
| name: "Build and publish docker" | |
| needs: create-release | |
| runs-on: [self-hosted, linux, X64] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Checkout latest release tag | |
| run: | | |
| LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) | |
| git checkout $LATEST_TAG | |
| echo "LATEST_TAG=${LATEST_TAG}" >> $GITHUB_ENV | |
| APP_VERSION=$(cat pyproject.toml | grep "version" | head -1 | cut -d'=' -f2 | xargs echo -n) | |
| echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ env.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v5 | |
| if: env.APP_VERSION == env.LATEST_TAG | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| sbom: true | |
| provenance: mode=max | |
| push: true | |
| tags: ${{ env.DOCKERHUB_ORG }}/${{ env.IMAGE_NAME }}:${{ env.APP_VERSION }} |