change H #53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto Release | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| actions: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Read current version | |
| id: current | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Check whether release exists | |
| id: check | |
| run: | | |
| TAG="v${{ steps.current.outputs.version }}" | |
| if git ls-remote --exit-code --tags origin "refs/tags/$TAG" >/dev/null 2>&1; then | |
| echo "Release tag $TAG already exists." | |
| echo "should_release=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "Release tag $TAG is missing." | |
| echo "should_release=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Stop if release exists | |
| if: steps.check.outputs.should_release != 'true' | |
| run: echo "Release already published." | |
| - name: Create tag + GitHub Release | |
| if: steps.check.outputs.should_release == 'true' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.current.outputs.version }} | |
| name: v${{ steps.current.outputs.version }} | |
| generate_release_notes: true | |
| - name: Dispatch Docker publication | |
| if: steps.check.outputs.should_release == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: gh workflow run docker-release.yml --repo "$GITHUB_REPOSITORY" --ref "$GITHUB_REF_NAME" |