Skip to content

Update Java setup action in SDK CI #6

Update Java setup action in SDK CI

Update Java setup action in SDK CI #6

Workflow file for this run

name: Create Release
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Read release version
id: version
run: |
version="$(tr -d '[:space:]' < VERSION)"
version="${version#v}"
if ! printf '%s' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$'; then
echo "VERSION must contain a semantic version like 1.2.3 or 1.2.3-beta.1"
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "tag=v$version" >> "$GITHUB_OUTPUT"
- name: Check whether the release already exists
id: existing
env:
GH_TOKEN: ${{ github.token }}
run: |
if gh release view "${{ steps.version.outputs.tag }}" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Check whether the tag already exists
id: tag
run: |
if git ls-remote --exit-code --tags origin "refs/tags/${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Create and push version tag
if: steps.tag.outputs.exists != 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag "${{ steps.version.outputs.tag }}" "$GITHUB_SHA"
git push origin "refs/tags/${{ steps.version.outputs.tag }}"
- name: Create GitHub release
if: steps.existing.outputs.exists != 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
for attempt in 1 2 3; do
if gh release create "${{ steps.version.outputs.tag }}" \
--repo "$GITHUB_REPOSITORY" \
--title "TPS ${{ steps.version.outputs.tag }}" \
--verify-tag \
--generate-notes; then
exit 0
fi
if [ "$attempt" -eq 3 ]; then
echo "Failed to create GitHub release after $attempt attempts."
exit 1
fi
echo "Release creation failed on attempt $attempt. Retrying..."
sleep 5
done