Repository navigation
Merge pull request #82 from coderbuzz/fix/safe-app-migration #350
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: Build and Publish | |
| on: | |
| push: | |
| tags: ['v*'] | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.25' | |
| - name: Vet | |
| run: go vet ./... | |
| - name: Test | |
| run: go test ./... | |
| - name: Smoke test | |
| run: bash scripts/smoke-test.sh | |
| - name: Build binary | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: | | |
| VERSION=$(echo "${GITHUB_REF##*/}" | sed 's/^v//') | |
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ | |
| -ldflags="-s -w -X main.version=${VERSION}" \ | |
| -o dockify-linux-amd64 \ | |
| ./cmd/dockify | |
| - name: Upload binary | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dockify-linux-amd64 | |
| path: dockify-linux-amd64 | |
| retention-days: 7 | |
| - name: Set up Docker Buildx | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Docker metadata | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=ref,event=tag | |
| type=raw,value=latest | |
| - name: Build and push Docker image | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| provenance: false | |
| build-args: | | |
| VERSION=${{ github.ref_name }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Clean up untagged Docker images | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| PACKAGE=$(echo '${{ github.repository }}' | cut -d'/' -f2) | |
| for id in $(gh api "/user/packages/container/${PACKAGE}/versions" \ | |
| --paginate -q '.[] | select(.metadata.container.tags == []) | .id'); do | |
| echo "Deleting untagged version $id" | |
| gh api -X DELETE "/user/packages/container/${PACKAGE}/versions/$id" | |
| done | |
| release: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dockify-linux-amd64 | |
| - name: Create release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: dockify-linux-amd64 | |
| generate_release_notes: true |