diff --git a/.github/workflows/create-ghcr-image-from-tag.yml b/.github/workflows/create-ghcr-image-from-tag.yml index cf126056..a8fe0dc0 100644 --- a/.github/workflows/create-ghcr-image-from-tag.yml +++ b/.github/workflows/create-ghcr-image-from-tag.yml @@ -9,10 +9,12 @@ env: REGISTRY: ghcr.io jobs: - publish-ghcr-image: - permissions: - packages: write + extract-service: runs-on: ubuntu-latest + outputs: + service: ${{ steps.getTagNameParts.outputs.service }} + version: ${{ steps.getTagNameParts.outputs.version }} + tag: ${{ steps.getTagNameParts.outputs.tag }} steps: - uses: olegtarasov/get-tag@v2.1.3 id: getTagNameParts @@ -32,49 +34,14 @@ jobs: echo "Version: $version" echo "tagFromAction: $tagFromAction" - - name: Check out Git repository - uses: actions/checkout@v4 - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - env: - service: ${{ steps.getTagNameParts.outputs.service }} - with: - cache: 'maven' - cache-dependency-path: ${{ steps.getTagNameParts.outputs.service }}/pom.xml - java-version: '17' - distribution: 'temurin' - - - name: build jar without tests - run: mvn -B -ntp -DskipTests package -f ${{ steps.getTagNameParts.outputs.service }}/pom.xml - - - name: Log in to the Container registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ github.repository }}-${{ steps.getTagNameParts.outputs.service }} - # tags: - # - Major - # - Major.Minor - # - full semver: 1.2.3 - # - latest - tags: | - type=match,pattern=(${{ steps.getTagNameParts.outputs.service }})/v(\d).\d.\d,group=2 - type=match,pattern=(${{ steps.getTagNameParts.outputs.service }})/v(\d.\d).\d,group=2 - type=match,pattern=(${{ steps.getTagNameParts.outputs.service }})/v(.*),group=2 - type=raw,value=latest - - - name: Build and push image - uses: docker/build-push-action@v5 - with: - context: ./${{ steps.getTagNameParts.outputs.service }} - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + publish-ghcr-image: + permissions: + packages: write + needs: + - extract-service + runs-on: ubuntu-latest + uses: + ./.github/workflows/callable-create-ghcr-image-from-tag.yml + with: + tag: ${{ needs.extract-service.outputs.service }}/v${{ needs.extract-service.outputs.version }} + service: ${{ needs.extract-service.outputs.service }} \ No newline at end of file diff --git a/.github/workflows/create-release-from-tag.yml b/.github/workflows/create-release-from-tag.yml index 90c2de70..2f9cf0aa 100644 --- a/.github/workflows/create-release-from-tag.yml +++ b/.github/workflows/create-release-from-tag.yml @@ -9,10 +9,12 @@ env: REGISTRY: ghcr.io jobs: - publish-ghcr-image: - permissions: - contents: write + extract-service: runs-on: ubuntu-latest + outputs: + service: ${{ steps.getTagNameParts.outputs.service }} + version: ${{ steps.getTagNameParts.outputs.version }} + tag: ${{ steps.getTagNameParts.outputs.tag }} steps: - uses: olegtarasov/get-tag@v2.1.3 id: getTagNameParts @@ -32,26 +34,14 @@ jobs: echo "Version: $version" echo "tagFromAction: $tagFromAction" - - name: Check out Git repository - uses: actions/checkout@v4 - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - cache: 'maven' - cache-dependency-path: '${{ steps.getTagNameParts.outputs.service }}/pom.xml' - java-version: '17' - distribution: 'temurin' - - - name: build jar without tests - run: mvn -B -ntp -DskipTests package -f ${{ steps.getTagNameParts.outputs.service }}/pom.xml - - - name: Create GitHub Release - id: create_release - uses: softprops/action-gh-release@v1 - with: - files: | - ${{ steps.getTagNameParts.outputs.service }}/target/*.jar - draft: false - prerelease: false - generate_release_notes: false \ No newline at end of file + publish-ghcr-image: + permissions: + contents: write + runs-on: ubuntu-latest + needs: + - extract-service + uses: + ./.github/workflows/callable-create-release-from-tag.yml + with: + tag: ${{ needs.extract-service.outputs.service }}/v${{ needs.extract-service.outputs.version }} + service: ${{ needs.extract-service.outputs.service }} \ No newline at end of file