diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9197c6d..e176fe8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -2,7 +2,6 @@ name: Build and Publish Docker Image on: push: branches: ["master"] - tags: ["*"] env: REGISTRY: ghcr.io @@ -13,7 +12,7 @@ jobs: runs-on: ubuntu-latest permissions: - contents: read + contents: write packages: write steps: @@ -28,14 +27,31 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Get next version + uses: reecetech/version-increment@2023.9.3 + id: version + with: + scheme: calver + increment: patch + + - name: Create tag + uses: actions/github-script@v5 + with: + script: | + github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'refs/tags/${{ steps.version.outputs.version }}', + sha: context.sha + }) + - name: Extract metadata to create tags and labels id: meta uses: docker/metadata-action@v5.5.1 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=semver,pattern={{version}} - type=semver,pattern={{version}},value={{date 'YY.M.D' tz='America/New_York'}},enabled={{is_default_branch}} + type=raw,value=${{steps.version.outputs.version}},priority=300 type=raw,value=latest,enable={{is_default_branch}} - name: Build and push Docker image