|
| 1 | +name: CD - Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master] |
| 6 | + |
| 7 | +concurrency: ${{ github.workflow }}-${{ github.ref }} |
| 8 | + |
| 9 | +env: |
| 10 | + GIT_USER_NAME: "TEAM 4.0[bot]" |
| 11 | + GIT_USER_EMAIL: "Team4.0@SINTEF.no" |
| 12 | + DEFAULT_REPO_BRANCH: master |
| 13 | + |
| 14 | +jobs: |
| 15 | + update_version: |
| 16 | + name: Update the version |
| 17 | + if: github.repository_owner == 'EMMC-ASBL' |
| 18 | + runs-on: ubuntu-latest |
| 19 | + outputs: |
| 20 | + continue_workflow: ${{ steps.update_version_step.outputs.continue_workflow }} |
| 21 | + |
| 22 | + permissions: |
| 23 | + contents: write |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout repository |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + |
| 31 | + - name: Set up git config |
| 32 | + run: | |
| 33 | + git config --global user.name "${{ env.GIT_USER_NAME }}" |
| 34 | + git config --global user.email "${{ env.GIT_USER_EMAIL }}" |
| 35 | +
|
| 36 | + - name: Set up Python 3.10 |
| 37 | + uses: actions/setup-python@v5 |
| 38 | + with: |
| 39 | + python-version: "3.10" |
| 40 | + |
| 41 | + - name: Install Python dependencies |
| 42 | + run: | |
| 43 | + python -m pip install -U pip |
| 44 | + pip install -U setuptools wheel |
| 45 | + pip install -U -r .dev/requirements_release.txt |
| 46 | +
|
| 47 | + - name: Update version |
| 48 | + id: update_version_step |
| 49 | + run: | |
| 50 | + invoke setver |
| 51 | +
|
| 52 | + if [ -n "$(git status --porcelain app/__init__.py)" ]; then |
| 53 | + echo "Version updated !" |
| 54 | + CONTINUE_WORKFLOW=true |
| 55 | + else |
| 56 | + # The version has not changed - i.e. the workflow shouldn't continue. |
| 57 | + echo "Version NOT updated !" |
| 58 | + CONTINUE_WORKFLOW=false |
| 59 | + fi |
| 60 | +
|
| 61 | + echo "continue_workflow=${CONTINUE_WORKFLOW}" >> $GITHUB_OUTPUT |
| 62 | +
|
| 63 | + - name: Update changelog |
| 64 | + if: steps.update_version_step.outputs.continue_workflow == 'true' |
| 65 | + uses: docker://githubchangeloggenerator/github-changelog-generator:1.16.2 |
| 66 | + with: |
| 67 | + args: --user "${{ github.repository_owner }}" --project "oteapi-services" --token "${{ secrets.RELEASE_PAT }}" --release-branch "${{ env.DEFAULT_REPO_BRANCH }}" --exclude-labels "skip-changelog,duplicate,question,invalid,wontfix" |
| 68 | + |
| 69 | + - name: Commit changes |
| 70 | + if: steps.update_version_step.outputs.continue_workflow == 'true' |
| 71 | + run: | |
| 72 | + git add app/__init__.py CHANGELOG.md |
| 73 | + git commit --amend -C HEAD |
| 74 | +
|
| 75 | + - name: Update '${{ env.DEFAULT_REPO_BRANCH }}' |
| 76 | + if: steps.update_version_step.outputs.continue_workflow == 'true' |
| 77 | + uses: CasperWA/push-protected@v2 |
| 78 | + with: |
| 79 | + token: ${{ secrets.RELEASE_PAT }} |
| 80 | + branch: ${{ env.DEFAULT_REPO_BRANCH }} |
| 81 | + sleep: 15 |
| 82 | + force: true |
| 83 | + unprotect_reviews: false |
| 84 | + |
| 85 | + publish_container_image: |
| 86 | + name: Publish Container image on GH Packages |
| 87 | + needs: update_version |
| 88 | + if: github.repository_owner == 'EMMC-ASBL' && needs.update_version.outputs.continue_workflow == 'true' |
| 89 | + uses: ./.github/workflows/ci_cd_docker.yml |
| 90 | + with: |
| 91 | + source_ref: 'master' # Must match DEFAULT_REPO_BRANCH - env context not available here |
| 92 | + image_name: oteapi |
| 93 | + image_owner: emmc-asbl |
| 94 | + registry_url: ghcr.io |
| 95 | + secrets: |
| 96 | + REGISTRY_USER: TEAM4-0 |
| 97 | + REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} |
| 98 | + PAT: ${{ secrets.RELEASE_PAT }} |
| 99 | + |
| 100 | + permissions: |
| 101 | + packages: write |
| 102 | + contents: read |
0 commit comments