|
| 1 | +name: release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + omada_version: |
| 10 | + description: "Omada version to build, for example 6.2.10.17" |
| 11 | + required: true |
| 12 | + omada_url: |
| 13 | + description: "Official TP-Link artifact URL. Leave empty to use release-manifests/omada-releases.json." |
| 14 | + required: false |
| 15 | + default: "" |
| 16 | + omada_sha256: |
| 17 | + description: "Trusted artifact SHA256. Leave empty to use release-manifests/omada-releases.json." |
| 18 | + required: false |
| 19 | + default: "" |
| 20 | + publish: |
| 21 | + description: "Push to GHCR. Requires repository variable TP_LINK_REDISTRIBUTION_OK=true." |
| 22 | + type: boolean |
| 23 | + required: true |
| 24 | + default: false |
| 25 | + |
| 26 | +permissions: |
| 27 | + contents: read |
| 28 | + packages: write |
| 29 | + |
| 30 | +env: |
| 31 | + IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/omada-controller |
| 32 | + TP_LINK_REDISTRIBUTION_OK: ${{ vars.TP_LINK_REDISTRIBUTION_OK }} |
| 33 | + |
| 34 | +jobs: |
| 35 | + build: |
| 36 | + runs-on: ubuntu-latest |
| 37 | + steps: |
| 38 | + - name: Check out repository |
| 39 | + uses: actions/checkout@v4 |
| 40 | + |
| 41 | + - name: Resolve Omada release |
| 42 | + id: release |
| 43 | + shell: bash |
| 44 | + run: | |
| 45 | + set -euo pipefail |
| 46 | +
|
| 47 | + if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then |
| 48 | + version="${GITHUB_REF_NAME#v}" |
| 49 | + publish_requested="true" |
| 50 | + input_url="" |
| 51 | + input_sha256="" |
| 52 | + else |
| 53 | + version="${{ inputs.omada_version }}" |
| 54 | + publish_requested="${{ inputs.publish }}" |
| 55 | + input_url="${{ inputs.omada_url }}" |
| 56 | + input_sha256="${{ inputs.omada_sha256 }}" |
| 57 | + fi |
| 58 | +
|
| 59 | + if [[ -z "${version}" ]]; then |
| 60 | + echo "Omada version is required" >&2 |
| 61 | + exit 1 |
| 62 | + fi |
| 63 | +
|
| 64 | + if [[ -n "${input_url}" || -n "${input_sha256}" ]]; then |
| 65 | + url="${input_url}" |
| 66 | + sha256="${input_sha256}" |
| 67 | + else |
| 68 | + url="$(jq -r --arg version "${version}" '.[$version].url // empty' release-manifests/omada-releases.json)" |
| 69 | + sha256="$(jq -r --arg version "${version}" '.[$version].sha256 // empty' release-manifests/omada-releases.json)" |
| 70 | + fi |
| 71 | +
|
| 72 | + if [[ -z "${url}" || -z "${sha256}" ]]; then |
| 73 | + echo "No release manifest entry found for Omada ${version}; provide omada_url and omada_sha256 manually." >&2 |
| 74 | + exit 1 |
| 75 | + fi |
| 76 | +
|
| 77 | + publish="false" |
| 78 | + if [[ "${publish_requested}" == "true" ]]; then |
| 79 | + if [[ "${TP_LINK_REDISTRIBUTION_OK}" != "true" ]]; then |
| 80 | + echo "Refusing to publish a public image containing TP-Link Omada binaries." >&2 |
| 81 | + echo "Set repository variable TP_LINK_REDISTRIBUTION_OK=true only after confirming redistribution permission." >&2 |
| 82 | + exit 1 |
| 83 | + fi |
| 84 | + publish="true" |
| 85 | + fi |
| 86 | +
|
| 87 | + { |
| 88 | + echo "version=${version}" |
| 89 | + echo "url=${url}" |
| 90 | + echo "sha256=${sha256}" |
| 91 | + echo "publish=${publish}" |
| 92 | + } >> "${GITHUB_OUTPUT}" |
| 93 | +
|
| 94 | + - name: Set up Docker Buildx |
| 95 | + uses: docker/setup-buildx-action@v3 |
| 96 | + |
| 97 | + - name: Log in to GHCR |
| 98 | + if: steps.release.outputs.publish == 'true' |
| 99 | + uses: docker/login-action@v3 |
| 100 | + with: |
| 101 | + registry: ghcr.io |
| 102 | + username: ${{ github.actor }} |
| 103 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 104 | + |
| 105 | + - name: Generate image metadata |
| 106 | + id: meta |
| 107 | + uses: docker/metadata-action@v5 |
| 108 | + with: |
| 109 | + images: ${{ env.IMAGE_NAME }} |
| 110 | + flavor: latest=false |
| 111 | + tags: | |
| 112 | + type=semver,pattern={{version}},value=v${{ steps.release.outputs.version }} |
| 113 | + type=semver,pattern={{major}}.{{minor}},value=v${{ steps.release.outputs.version }} |
| 114 | + type=semver,pattern={{major}},value=v${{ steps.release.outputs.version }} |
| 115 | + labels: | |
| 116 | + org.opencontainers.image.title=Omada Controller Docker Compose |
| 117 | + org.opencontainers.image.description=TP-Link Omada Software Controller image for Docker Compose with external MongoDB |
| 118 | + org.opencontainers.image.version=${{ steps.release.outputs.version }} |
| 119 | +
|
| 120 | + - name: Build image |
| 121 | + uses: docker/build-push-action@v6 |
| 122 | + with: |
| 123 | + context: . |
| 124 | + file: Dockerfile |
| 125 | + platforms: linux/amd64 |
| 126 | + push: ${{ steps.release.outputs.publish == 'true' }} |
| 127 | + tags: ${{ steps.meta.outputs.tags }} |
| 128 | + labels: ${{ steps.meta.outputs.labels }} |
| 129 | + build-args: | |
| 130 | + OMADA_VERSION=${{ steps.release.outputs.version }} |
| 131 | + OMADA_URL=${{ steps.release.outputs.url }} |
| 132 | + OMADA_SHA256=${{ steps.release.outputs.sha256 }} |
| 133 | +
|
| 134 | + - name: Print image tags |
| 135 | + run: | |
| 136 | + if [[ "${{ steps.release.outputs.publish }}" == "true" ]]; then |
| 137 | + echo "Published:" |
| 138 | + else |
| 139 | + echo "Built without publishing:" |
| 140 | + fi |
| 141 | + echo "${{ steps.meta.outputs.tags }}" |
0 commit comments