Merge pull request #107 from leaseweb/feat/crd_migrator #158
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 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - develop | |
| tags: | |
| - v* | |
| env: | |
| REGISTRY: ghcr.io/leaseweb | |
| IMAGE_NAME: capi-cloudstack-controller | |
| jobs: | |
| push: | |
| name: Push images | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| # This step is run when the branch is main and no tag is set | |
| - name: Sets env vars for main | |
| run: | | |
| echo "TAG=latest" >> $GITHUB_ENV | |
| if: github.ref == 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/v') | |
| # This step is run when the branch is develop | |
| - name: Sets env vars for develop | |
| run: | | |
| echo "TAG=develop" >> $GITHUB_ENV | |
| if: github.ref == 'refs/heads/develop' | |
| # This step is run when there is a tag | |
| - name: Sets env vars for tag | |
| run: | | |
| VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,' | sed -e 's/^v//') | |
| echo "TAG=${VERSION}" >> $GITHUB_ENV | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| - name: Cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - name: Build container images | |
| run: make docker-build | |
| - name: Log into registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{github.actor}} | |
| password: ${{secrets.GITHUB_TOKEN}} | |
| - name: Push | |
| run: | | |
| docker push ${REGISTRY}/${IMAGE_NAME}:${TAG} | |
| release: | |
| name: Release | |
| runs-on: ubuntu-22.04 | |
| # Run only if previous job has succeeded | |
| needs: [push] | |
| # Create a release only for tags v* | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Sets env vars for tag | |
| run: | | |
| VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,' | sed -e 's/^v//') | |
| echo "TAG=${VERSION}" >> $GITHUB_ENV | |
| - name: Build release manifests | |
| run: make release-manifests | |
| - name: Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| prerelease: false | |
| draft: true | |
| fail_on_unmatched_files: true | |
| generate_release_notes: true | |
| name: ${{ env.TAG }} | |
| files: | | |
| out/metadata.yaml | |
| out/infrastructure-components.yaml |