|
| 1 | +name: Publish |
| 2 | + |
| 3 | +env: |
| 4 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + bump: |
| 10 | + description: Version bump to publish |
| 11 | + required: true |
| 12 | + default: patch |
| 13 | + type: choice |
| 14 | + options: |
| 15 | + - patch |
| 16 | + - minor |
| 17 | + - major |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: write |
| 21 | + packages: write |
| 22 | + |
| 23 | +concurrency: |
| 24 | + group: publish-${{ github.ref }} |
| 25 | + cancel-in-progress: false |
| 26 | + |
| 27 | +jobs: |
| 28 | + publish: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + |
| 31 | + steps: |
| 32 | + - name: Check out repository |
| 33 | + uses: actions/checkout@v4 |
| 34 | + with: |
| 35 | + fetch-depth: 0 |
| 36 | + |
| 37 | + - name: Set up Go |
| 38 | + uses: actions/setup-go@v5 |
| 39 | + with: |
| 40 | + go-version-file: go.mod |
| 41 | + cache: true |
| 42 | + |
| 43 | + - name: Run Go tests |
| 44 | + run: go test ./... |
| 45 | + |
| 46 | + - name: Bump version and create tag |
| 47 | + id: version |
| 48 | + uses: mathieudutour/github-tag-action@v6.2 |
| 49 | + with: |
| 50 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + tag_prefix: v |
| 52 | + default_bump: ${{ inputs.bump }} |
| 53 | + initial_version: 0.1.0 |
| 54 | + |
| 55 | + - name: Fetch tags for changelog range |
| 56 | + shell: bash |
| 57 | + run: git fetch --force --tags origin |
| 58 | + |
| 59 | + - name: Run GoReleaser |
| 60 | + uses: goreleaser/goreleaser-action@v7 |
| 61 | + with: |
| 62 | + distribution: goreleaser |
| 63 | + version: "~> v2" |
| 64 | + args: release --clean |
| 65 | + env: |
| 66 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + GORELEASER_CURRENT_TAG: ${{ steps.version.outputs.new_tag }} |
| 68 | + |
| 69 | + - name: Set up QEMU |
| 70 | + uses: docker/setup-qemu-action@v3 |
| 71 | + |
| 72 | + - name: Set up Docker Buildx |
| 73 | + uses: docker/setup-buildx-action@v3 |
| 74 | + |
| 75 | + - name: Log in to GitHub Container Registry |
| 76 | + uses: docker/login-action@v3 |
| 77 | + with: |
| 78 | + registry: ghcr.io |
| 79 | + username: ${{ github.actor }} |
| 80 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 81 | + |
| 82 | + - name: Extract Docker metadata |
| 83 | + id: meta |
| 84 | + uses: docker/metadata-action@v5 |
| 85 | + with: |
| 86 | + images: ghcr.io/${{ github.repository_owner }}/meshd |
| 87 | + tags: | |
| 88 | + type=raw,value=latest,enable={{is_default_branch}} |
| 89 | + type=raw,value=main |
| 90 | + type=raw,value=${{ steps.version.outputs.new_tag }} |
| 91 | + type=sha,format=short,prefix=sha- |
| 92 | +
|
| 93 | + - name: Build and push Docker image |
| 94 | + uses: docker/build-push-action@v6 |
| 95 | + with: |
| 96 | + context: . |
| 97 | + platforms: linux/amd64,linux/arm64 |
| 98 | + push: true |
| 99 | + tags: ${{ steps.meta.outputs.tags }} |
| 100 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments