name: Build and Publish Docker Image and Release on: push: tags: - 'v*' jobs: build-docker: runs-on: ubuntu-latest env: IMAGE_NAME: ppanel-server steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log in to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Extract version from git tag id: version run: | VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//') echo "VERSION=$VERSION" BUILD_NUMBER=$(echo $VERSION | tr -d '.' | sed 's/^0*//') echo "BUILD_NUMBER=$BUILD_NUMBER" echo "VERSION=$VERSION" >> $GITHUB_ENV echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV - name: Get short SHA id: sha run: echo "GIT_SHA=${GITHUB_SHA::8}" >> $GITHUB_ENV - name: Build and push Docker image for main release if: "!contains(github.ref_name, 'beta')" uses: docker/build-push-action@v6 with: context: . file: Dockerfile platforms: linux/amd64,linux/arm64 push: true tags: | ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}-${{ env.BUILD_NUMBER }} - name: Build and push Docker image for beta release if: contains(github.ref_name, 'beta') uses: docker/build-push-action@v6 with: context: . file: Dockerfile platforms: linux/amd64,linux/arm64 push: true tags: | ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:beta ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}-beta ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}-${{ env.BUILD_NUMBER }}-beta release-notes: runs-on: ubuntu-latest needs: build-docker steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Go uses: actions/setup-go@v5 with: go-version: '1.21' - name: Install GoReleaser run: | go install github.com/goreleaser/goreleaser/v2@latest - name: Run GoReleaser env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} run: | goreleaser check goreleaser release --clean releases-matrix: name: Release ppanel-server binary runs-on: ubuntu-latest needs: release-notes strategy: matrix: goos: [ linux, windows, darwin ] goarch: [ '386', amd64, arm64 ] exclude: - goos: darwin goarch: '386' include: - goos: linux goarch: arm goarm: 5 target: linux-armv5 - goos: linux goarch: arm goarm: 6 target: linux-armv6 - goos: linux goarch: arm goarm: 7 target: linux-armv7 - goos: windows goarch: arm goarm: 7 target: windows-armv7 - goos: linux goarch: amd64 goamd64: v3 target: linux-amd64-v3 - goos: windows goarch: amd64 goamd64: v3 target: windows-amd64-v3 - goos: darwin goarch: amd64 goamd64: v3 target: darwin-amd64-v3 steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 with: go-version: '1.21' - name: Build binary with Makefile env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} GOARM: ${{ matrix.goarm }} GOMIPS: ${{ matrix.gomips }} run: | # Use default target for non-special architectures, otherwise use matrix.target TARGET=${{ matrix.target != '' && matrix.target || format('{0}-{1}', matrix.goos, matrix.goarch) }} make BINDIR=bin $TARGET mv bin/ppanel-server-$TARGET* ppanel-server-$TARGET - name: Upload release asset uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ github.event.release.upload_url }} asset_path: ppanel-server-${{ matrix.target != '' && matrix.target || format('{0}-{1}', matrix.goos, matrix.goarch) }} asset_name: ppanel-server-${{ matrix.target != '' && matrix.target || format('{0}-{1}', matrix.goos, matrix.goarch) }}${{ matrix.goos == 'windows' && '.exe' || '' }} asset_content_type: application/octet-stream - name: Upload additional files uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ github.event.release.upload_url }} asset_path: etc/ppanel.yaml asset_name: ppanel.yaml asset_content_type: text/yaml - name: Upload LICENSE uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ github.event.release.upload_url }} asset_path: LICENSE asset_name: LICENSE asset_content_type: text/plain