feat: repo mgmt apis (#29) #15
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: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| concurrency: | |
| group: release-${{ github.ref_name }} | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| release: | |
| name: Publish release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-go@v7.0.0 | |
| with: | |
| go-version-file: go.mod | |
| - name: Validate release tag | |
| env: | |
| TAG: ${{ github.ref_name }} | |
| run: | | |
| semver='^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*)|([0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*))(\.((0|[1-9][0-9]*)|([0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*)))*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$' | |
| if [[ ! "$TAG" =~ $semver ]]; then | |
| echo "Tag $TAG is not a valid v-prefixed SemVer 2.0 version" >&2 | |
| exit 1 | |
| fi | |
| - name: Release with GoReleaser | |
| uses: goreleaser/goreleaser-action@v7 | |
| with: | |
| distribution: goreleaser | |
| version: '~> v2' | |
| args: release --clean | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4.3.0 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v4.6.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Generate Docker image metadata | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: ghcr.io/trly/pkgdepot | |
| tags: | | |
| type=semver,pattern={{version}} | |
| - name: Verify release image tag is unused | |
| env: | |
| IMAGE_TAG: ${{ steps.meta.outputs.tags }} | |
| run: | | |
| if docker buildx imagetools inspect "$IMAGE_TAG" >/dev/null 2>&1; then | |
| echo "Release image tag already exists: $IMAGE_TAG" >&2 | |
| exit 1 | |
| fi | |
| - name: Publish release image | |
| id: publish | |
| uses: docker/build-push-action@v7.3.0 | |
| with: | |
| context: . | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| - name: Report canonical image reference | |
| env: | |
| IMAGE: ghcr.io/trly/pkgdepot | |
| DIGEST: ${{ steps.publish.outputs.digest }} | |
| run: 'echo "Canonical image: ${IMAGE}@${DIGEST}"' |