diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ad0b6c8..b79c20c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,12 @@ on: push: tags: - '*' + workflow_call: + inputs: + version: + description: Version tag to publish (e.g. 1.0.0-beta.13) + required: false + type: string jobs: publish-to-dockerhub: @@ -24,6 +30,9 @@ jobs: uses: docker/metadata-action@v6 with: images: codfish/json-server + tags: | + type=raw,value=${{ inputs.version }},enable=${{ inputs.version != '' }} + type=ref,event=tag,enable=${{ inputs.version == '' }} - name: Build and push Docker image uses: docker/build-push-action@v7 diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index aacff66..7fa483b 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -12,6 +12,8 @@ jobs: auto-tag: name: Auto-tag based on json-server version runs-on: ubuntu-latest + outputs: + version: ${{ steps.tag.outputs.version }} steps: - name: Check out the repo uses: actions/checkout@v6 @@ -19,6 +21,7 @@ jobs: fetch-depth: 0 - name: Create or update tag + id: tag run: | VERSION=$(jq -r '.dependencies["json-server"]' package.json) if [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; then @@ -27,6 +30,7 @@ jobs: fi LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "json-server version: $VERSION" echo "Latest tag: $LATEST_TAG" @@ -42,3 +46,10 @@ jobs: git tag -a "$VERSION" -m "$VERSION" git push origin "$VERSION" --force fi + + release: + needs: auto-tag + uses: ./.github/workflows/release.yml + with: + version: ${{ needs.auto-tag.outputs.version }} + secrets: inherit