Build and push docker images after release (#1289) #2
Workflow file for this run
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: "Release and Publish" | |
| on: | |
| push: | |
| tags: | |
| - "*" | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set TERM environment variable | |
| run: echo "TERM=xterm" >> $GITHUB_ENV | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.13" | |
| - name: Install dependencies | |
| run: make bootstrap-dev | |
| - name: Get tag name | |
| id: tag | |
| run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| - name: Update all version references | |
| run: | | |
| TAG="${{ steps.tag.outputs.tag }}" | |
| VERSION_PATTERN="[0-9]\+\.[0-9]\+\.[0-9]\+" | |
| # Update galaxy.yml version | |
| sed -i "s/^version:.*/version: ${TAG}/" \ | |
| automation/galaxy.yml | |
| # Update automation README version | |
| sed -i "s/version: ${VERSION_PATTERN}/version: ${TAG}/" \ | |
| automation/README.md | |
| # Update console docker-compose.yml image tags | |
| sed -i "s/autobase\/console_api:${VERSION_PATTERN}/autobase\/console_api:${TAG}/g" \ | |
| console/docker-compose.yml | |
| sed -i "s/autobase\/console_ui:${VERSION_PATTERN}/autobase\/console_ui:${TAG}/g" \ | |
| console/docker-compose.yml | |
| sed -i "s/autobase\/console_db:${VERSION_PATTERN}/autobase\/console_db:${TAG}/g" \ | |
| console/docker-compose.yml | |
| # Update console service VERSION file | |
| echo "${TAG}" > console/service/VERSION | |
| # Update console service README version | |
| sed -i "s/autobase\/automation:${VERSION_PATTERN}/autobase\/automation:${TAG}/g" \ | |
| console/service/README.md | |
| # Update swagger.yaml version | |
| sed -i "s/^ version: ${VERSION_PATTERN}/ version: ${TAG}/" \ | |
| console/service/api/swagger.yaml | |
| # Update config.go version | |
| sed -i "s/autobase\/automation:${VERSION_PATTERN}/autobase\/automation:${TAG}/g" \ | |
| console/service/internal/configuration/config.go | |
| # Update package.json version | |
| sed -i "s/\"version\": \"${VERSION_PATTERN}\"/\"version\": \"${TAG}\"/" \ | |
| console/ui/package.json | |
| - name: Commit version changes to main branch | |
| run: | | |
| TAG="${{ steps.tag.outputs.tag }}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| # Add all changed files | |
| git add \ | |
| automation/galaxy.yml \ | |
| automation/README.md \ | |
| console/docker-compose.yml \ | |
| console/service/VERSION \ | |
| console/service/README.md \ | |
| console/service/api/swagger.yaml \ | |
| console/service/internal/configuration/config.go \ | |
| console/ui/package.json | |
| # Check if there are changes to commit | |
| if ! git diff --staged --quiet; then | |
| git commit -m "chore: release ${TAG}" | |
| git push origin HEAD:${{ github.event.repository.default_branch }} | |
| fi | |
| - name: Build Ansible collection | |
| run: | | |
| cd automation | |
| ansible-galaxy collection build | |
| - name: Publish to Ansible Galaxy | |
| run: | | |
| cd automation | |
| ansible-galaxy collection publish \ | |
| vitabaks-autobase-${{ steps.tag.outputs.tag }}.tar.gz \ | |
| --token $ANSIBLE_GALAXY_TOKEN | |
| env: | |
| ANSIBLE_GALAXY_TOKEN: ${{ secrets.ANSIBLE_GALAXY_TOKEN }} | |
| - name: Build release image | |
| run: make docker-build | |
| env: | |
| TAG: ${{ env.TAG }} | |
| - name: Push release image | |
| if: ${{ env.DOCKER_REGISTRY_USER != '' && env.DOCKER_REGISTRY_PASSWORD != '' }} | |
| run: make docker-push | |
| env: | |
| TAG: ${{ env.TAG }} | |
| DOCKER_REGISTRY_USER: ${{ secrets.DOCKER_USERNAME }} | |
| DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |