Skip to content

Commit

Permalink
fix: flow
Browse files Browse the repository at this point in the history
  • Loading branch information
nana4rider committed Jan 23, 2025
1 parent ba4c259 commit ae55c5c
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,54 @@ jobs:
test:
uses: ./.github/workflows/test.yml

get-version:
prepare-release:
needs: test
runs-on: ubuntu-latest
outputs:
current: ${{ steps.current.outputs.version }}
previous: ${{ steps.previous.outputs.version }}
current_version: ${{ steps.version.outputs.current_version }}
tag_exists: ${{ steps.tag_check.outputs.tag_exists }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
fetch-depth: 0
fetch-tags: true

- id: current
- id: version
run: |
VERSION=$(jq -r '.version' package.json)
echo "current: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
CURRENT_VERSION=$(jq -r '.version' package.json)
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
- id: previous
- id: tag_check
run: |
VERSION=$(git show HEAD~1:package.json | jq -r '.version')
echo "previous: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
if git rev-parse "v${{ steps.version.outputs.current_version }}" >/dev/null 2>&1; then
echo "tag_exists=true" >> $GITHUB_OUTPUT
else
echo "tag_exists=false" >> $GITHUB_OUTPUT
fi
release:
runs-on: ubuntu-latest
needs: get-version
if: ${{ github.event_name == 'workflow_dispatch' || needs.get-version.outputs.current != needs.get-version.outputs.previous }}
needs: prepare-release
if: ${{ needs.prepare-release.outputs.tag_exists == 'false' }}
steps:
- uses: actions/checkout@v4

- name: Add Tag
run: |
git tag "v${{ needs.get-version.outputs.current }}"
git push origin "v${{ needs.get-version.outputs.current }}"
git tag "v${{ needs.prepare-release.outputs.current_version }}"
git push origin "v${{ needs.prepare-release.outputs.current_version }}"
- name: Create Release to GitHub
run: gh release create "v${{ needs.get-version.outputs.current }}" --generate-notes
run: gh release create "v${{ needs.prepare-release.outputs.current_version }}" --generate-notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-and-publish:
runs-on: ubuntu-latest
needs: get-version
if: ${{ github.event_name == 'workflow_dispatch' || needs.get-version.outputs.current != needs.get-version.outputs.previous }}
needs: prepare-release
if: ${{ needs.prepare-release.outputs.tag_exists == 'false' }}
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand All @@ -71,7 +72,7 @@ jobs:
images: ${{ github.repository }}
tags: |
type=raw,value=latest
type=raw,value=v${{ needs.get-version.outputs.current }}
type=raw,value=v${{ needs.prepare-release.outputs.current_version }}
- name: Login to Docker Hub
uses: docker/login-action@v3
Expand Down

0 comments on commit ae55c5c

Please sign in to comment.