|
| 1 | +name: Production Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: production-release |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +jobs: |
| 13 | + # ------------------------------------------------------------------ |
| 14 | + # JOB 1: RELEASE (Calculate Version, Tag, Push to PyPI) |
| 15 | + # ------------------------------------------------------------------ |
| 16 | + release: |
| 17 | + name: Semantic Release |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + contents: write # Needed to create releases/tags |
| 21 | + id-token: write # Needed for PyPI trusted publishing |
| 22 | + outputs: |
| 23 | + released: ${{ steps.semantic.outputs.released }} |
| 24 | + tag: ${{ steps.semantic.outputs.tag }} |
| 25 | + version: ${{ steps.semantic.outputs.version }} |
| 26 | + |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 29 | + with: |
| 30 | + fetch-depth: 0 |
| 31 | + |
| 32 | + - name: Python Semantic Release |
| 33 | + id: semantic |
| 34 | + uses: python-semantic-release/python-semantic-release@7f12e960334860b29ce37894a485596489438914 # v9.15.0 |
| 35 | + with: |
| 36 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + |
| 38 | + - name: Publish to PyPI |
| 39 | + if: steps.semantic.outputs.released == 'true' |
| 40 | + uses: pypa/gh-action-pypi-publish@67339c736fd9352e5f1a7421053be3d68444052f # release/v1 |
| 41 | + with: |
| 42 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 43 | + |
| 44 | + # ------------------------------------------------------------------ |
| 45 | + # JOB 2: COPR BUILD (Fedora SRPM) |
| 46 | + # ------------------------------------------------------------------ |
| 47 | + copr_build: |
| 48 | + name: Submit to COPR |
| 49 | + needs: release |
| 50 | + if: needs.release.outputs.released == 'true' |
| 51 | + runs-on: ubuntu-latest |
| 52 | + container: fedora:latest |
| 53 | + permissions: |
| 54 | + contents: read |
| 55 | + |
| 56 | + steps: |
| 57 | + - name: Install Git |
| 58 | + run: dnf -y install git |
| 59 | + |
| 60 | + - name: Checkout Tagged Release |
| 61 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 62 | + with: |
| 63 | + ref: ${{ needs.release.outputs.tag }} |
| 64 | + |
| 65 | + - name: Install tooling |
| 66 | + run: | |
| 67 | + dnf -y install @development-tools @rpm-development-tools copr-cli make zlib-devel |
| 68 | +
|
| 69 | + - name: Work around GHA permission issue |
| 70 | + run: git config --global --add safe.directory /__w/badfish/badfish |
| 71 | + |
| 72 | + - name: Setup COPR Config |
| 73 | + env: |
| 74 | + API_TOKEN_CONTENT: ${{ secrets.COPR_API_TOKEN }} |
| 75 | + run: | |
| 76 | + mkdir -p "$HOME/.config" |
| 77 | + echo "$API_TOKEN_CONTENT" > "$HOME/.config/copr" |
| 78 | +
|
| 79 | + - name: Sync Spec Version and Build |
| 80 | + env: |
| 81 | + RELEASE_VERSION: ${{ needs.release.outputs.version }} |
| 82 | + run: | |
| 83 | + cd rpm |
| 84 | + sed -i "s/^Version:.*/Version: ${RELEASE_VERSION}/" python3-badfish.spec |
| 85 | + make srpm |
| 86 | + SRPM_FILE=$(find . -name "*.src.rpm" -type f | head -n 1) |
| 87 | + if [ -z "$SRPM_FILE" ]; then |
| 88 | + echo "Error: No .src.rpm file found in $(pwd) or subdirectories." |
| 89 | + echo "Ensure your Makefile outputs the SRPM locally or defines _topdir." |
| 90 | + exit 1 |
| 91 | + fi |
| 92 | + echo "Found SRPM: $SRPM_FILE" |
| 93 | + copr build quadsdev/badfish "$SRPM_FILE" |
| 94 | + # ------------------------------------------------------------------ |
| 95 | + # JOB 3: QUAY PUBLISH (Master & Latest) |
| 96 | + # ------------------------------------------------------------------ |
| 97 | + quay_master: |
| 98 | + name: Push Quay (Master) |
| 99 | + needs: release |
| 100 | + if: needs.release.outputs.released == 'true' |
| 101 | + runs-on: ubuntu-latest |
| 102 | + permissions: |
| 103 | + contents: read |
| 104 | + |
| 105 | + steps: |
| 106 | + - name: Checkout Tagged Release |
| 107 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 108 | + with: |
| 109 | + ref: ${{ needs.release.outputs.tag }} |
| 110 | + |
| 111 | + - name: Podman Login |
| 112 | + env: |
| 113 | + QUAY_USER: ${{ secrets.QUAY_USERNAME }} |
| 114 | + QUAY_TOKEN: ${{ secrets.QUAY_API_TOKEN }} |
| 115 | + run: echo "$QUAY_TOKEN" | podman login -u="$QUAY_USER" --password-stdin quay.io |
| 116 | + |
| 117 | + - name: Clean Old Tags |
| 118 | + env: |
| 119 | + QUAY_USER: ${{ secrets.QUAY_USERNAME }} |
| 120 | + QUAY_TOKEN: ${{ secrets.QUAY_API_TOKEN }} |
| 121 | + run: | |
| 122 | + REPO="quay.io/quads/badfish" |
| 123 | + echo "$QUAY_TOKEN" | skopeo login -u="$QUAY_USER" --password-stdin quay.io |
| 124 | +
|
| 125 | + # Delete 'master' and 'latest' if they exist |
| 126 | + for tag in master latest; do |
| 127 | + echo "Attempting to delete old tag: $tag" |
| 128 | + skopeo delete "docker://$REPO:$tag" || echo "Tag $tag not found or already deleted." |
| 129 | + done |
| 130 | +
|
| 131 | + - name: Build and Push |
| 132 | + run: | |
| 133 | + # Added --no-cache to ensure fresh layers |
| 134 | + podman build --no-cache -t quay.io/quads/badfish:master . |
| 135 | + podman tag quay.io/quads/badfish:master quay.io/quads/badfish:latest |
| 136 | + podman push quay.io/quads/badfish:master |
| 137 | + podman push quay.io/quads/badfish:latest |
0 commit comments