Repository navigation
Merge pull request #12 from reoring/feat/subworkflow-completion-check #7
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 | |
| - master | |
| paths: | |
| - package.json | |
| permissions: | |
| contents: write | |
| actions: write | |
| concurrency: | |
| group: auto-release-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| tag: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Resolve tag from package.json | |
| id: meta | |
| shell: bash | |
| run: | | |
| VERSION=$(node -e "const fs=require('node:fs'); const p=JSON.parse(fs.readFileSync('package.json','utf8')); process.stdout.write(String(p.version||''));") | |
| if [[ -z "$VERSION" ]]; then | |
| echo "package.json version is empty" >&2 | |
| exit 1 | |
| fi | |
| TAG="v${VERSION}" | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| - name: Create and push tag (if missing) | |
| id: tagger | |
| shell: bash | |
| env: | |
| TAG: ${{ steps.meta.outputs.tag }} | |
| run: | | |
| CREATED=0 | |
| if git ls-remote --tags origin "refs/tags/${TAG}" | grep -q "refs/tags/${TAG}$"; then | |
| echo "Tag already exists: ${TAG}" | |
| else | |
| GIT_AUTHOR_NAME="github-actions[bot]" \ | |
| GIT_AUTHOR_EMAIL="41898282+github-actions[bot]@users.noreply.github.com" \ | |
| GIT_COMMITTER_NAME="github-actions[bot]" \ | |
| GIT_COMMITTER_EMAIL="41898282+github-actions[bot]@users.noreply.github.com" \ | |
| git tag -a "${TAG}" -m "Release ${TAG}" | |
| git push origin "${TAG}" | |
| CREATED=1 | |
| fi | |
| echo "created=${CREATED}" >> "$GITHUB_OUTPUT" | |
| - name: Dispatch release workflow | |
| if: steps.tagger.outputs.created == '1' | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TAG: ${{ steps.meta.outputs.tag }} | |
| run: | | |
| gh workflow run release --field tag="$TAG" |