new prerelease test #103
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: Docker Build & Push All Services | |
| on: | |
| delete: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| - "v*.*.*-*" | |
| release: | |
| types: [published] | |
| jobs: | |
| debug: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: π Show event name and action | |
| run: | | |
| echo "ref ${{ github.ref }}" | |
| echo "event_ref ${{ github.event.ref }}" | |
| echo "ref_type: ${{ github.event.ref_type }}" | |
| echo "event_name: ${{ github.event_name }}" | |
| echo "event_action: ${{ github.event.action }}" | |
| discover: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| steps: | |
| - name: π§Ύ Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: π§ Discover components and services | |
| id: set-matrix | |
| run: | | |
| # Customize these lists as needed | |
| mkdir -p .build/tmp_matrix | |
| echo '{ "include": [' > .build/tmp_matrix/matrix.json | |
| FIRST=true | |
| for comp in subvortex/*; do | |
| [ -d "$comp" ] || continue | |
| comp_name=$(basename "$comp") | |
| for service in "$comp"/*; do | |
| [ -d "$service" ] || continue | |
| service_name=$(basename "$service") | |
| # β Include only if it has a pyproject or version.py | |
| if [[ -f "$service/pyproject.toml" || -f "$service/version.py" ]]; then | |
| if [ "$FIRST" = true ]; then | |
| FIRST=false | |
| else | |
| echo "," >> .build/tmp_matrix/matrix.json | |
| fi | |
| echo " { \"component\": \"$comp_name\", \"service\": \"$service_name\" }" >> .build/tmp_matrix/matrix.json | |
| fi | |
| done | |
| done | |
| echo "] }" >> .build/tmp_matrix/matrix.json | |
| echo "matrix<<EOF" >> $GITHUB_OUTPUT | |
| cat .build/tmp_matrix/matrix.json >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| echo "π Final matrix ready." | |
| build: | |
| if: github.event_name == 'push' || github.event_name == 'delete' | |
| needs: [discover] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| include: ${{ fromJson(needs.discover.outputs.matrix).include }} | |
| steps: | |
| - name: π§Ύ Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: π Set up QEMU | |
| uses: docker/setup-qemu-action@v2 | |
| - name: π§± Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: π Docker Login | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: π§ Generate build tag from hash | |
| id: meta | |
| run: | | |
| HASH=$(sha256sum subvortex/core/Dockerfile.builder | cut -d ' ' -f1) | |
| echo "tag=subvortex/subvortex-wheel-builder:3.11-$HASH" >> $GITHUB_OUTPUT | |
| - name: π Build & push wheel-builder (only if not exists) | |
| if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push' | |
| id: wheelbuilder | |
| run: | | |
| TAG="${{ steps.meta.outputs.tag }}" | |
| LATEST_TAG="subvortex/subvortex-wheel-builder:latest" | |
| if docker pull "$TAG" >/dev/null 2>&1; then | |
| echo "β Image already exists: $TAG" | |
| else | |
| echo "π Building wheel-builder image" | |
| docker buildx build \ | |
| --platform linux/amd64 \ | |
| --tag "$TAG" \ | |
| --tag "$LATEST_TAG" \ | |
| --file subvortex/core/Dockerfile.builder \ | |
| --push \ | |
| . | |
| fi | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| - name: π§ Determine tag and floating tags | |
| id: taginfo | |
| run: | | |
| TAG="${GITHUB_REF#refs/tags/}" | |
| echo "version_tag=$TAG" >> $GITHUB_OUTPUT | |
| FLOATING_TAGS="dev" | |
| if [[ "$TAG" == *-rc* ]]; then | |
| FLOATING_TAGS="dev stable" | |
| elif [[ "$TAG" != *-* ]]; then | |
| FLOATING_TAGS="dev stable latest" | |
| fi | |
| echo "floating_tags=$FLOATING_TAGS" >> $GITHUB_OUTPUT | |
| - name: π Build and push version-tagged image (on tag push only) | |
| if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push' | |
| run: | | |
| .github/scripts/on_tag_pushed.sh \ | |
| "${{ matrix.component }}" \ | |
| "${{ matrix.service }}" \ | |
| "${{ steps.meta.outputs.tag }}" \ | |
| "${{ steps.taginfo.outputs.version_tag }}" | |
| - name: π§Ή Remove version-tagged image (on tag delete) | |
| if: github.event_name == 'delete' && github.event.ref_type == 'tag' | |
| run: | | |
| .github/scripts/on_tag_deleted.sh "${{ matrix.component }}" "${{ matrix.service }}" "${{ github.event.ref }}" | |
| env: | |
| DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
| DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
| release: | |
| if: github.event_name == 'release' | |
| needs: [discover] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| include: ${{ fromJson(needs.discover.outputs.matrix).include }} | |
| steps: | |
| - name: π§Ύ Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: π Set up QEMU | |
| uses: docker/setup-qemu-action@v2 | |
| - name: π§± Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: π Docker Login | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: π§ Determine tag and floating tags | |
| id: taginfo | |
| run: | | |
| TAG="${GITHUB_REF#refs/tags/}" | |
| echo "version_tag=$TAG" >> $GITHUB_OUTPUT | |
| FLOATING_TAGS="dev" | |
| if [[ "$TAG" == *-rc* ]]; then | |
| FLOATING_TAGS="dev stable" | |
| elif [[ "$TAG" != *-* ]]; then | |
| FLOATING_TAGS="dev stable latest" | |
| fi | |
| echo "floating_tags=$FLOATING_TAGS" >> $GITHUB_OUTPUT | |
| - name: π Retag and push floating tags (on release or prerelease) | |
| if: github.event_name == 'release' && github.event.action != 'deleted' | |
| run: | | |
| .github/scripts/on_release_pushed.sh \ | |
| "${{ matrix.component }}" \ | |
| "${{ matrix.service }}" \ | |
| "${{ steps.taginfo.outputs.version_tag }}" \ | |
| "${{ github.event.release.prerelease }}" \ | |
| "${{ github.event.release.draft }}" | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |