Check Version and Release #98
This file contains 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: Check Version and Release | |
on: | |
schedule: | |
- cron: '0 0 * * 1,3,5' | |
workflow_dispatch: | |
jobs: | |
check_and_release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set Up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 'lts/*' | |
cache: 'yarn' | |
- name: Get Version from JSON | |
run: | | |
DEFOLD_VERSION=$(curl -s https://d.defold.com/stable/info.json | jq -r .version) | |
PACKAGE_VERSION=$(node -p "require('./package.json').version") | |
echo "DEFOLD_VERSION=${DEFOLD_VERSION}" >> $GITHUB_ENV | |
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV | |
- name: Bump Version | |
run: | | |
if [ "${DEFOLD_VERSION}" == "${PACKAGE_VERSION}" ]; then | |
echo "${DEFOLD_VERSION} already exists. Skipping bump version." | |
exit 0 | |
else | |
# Bump Version | |
git config user.email "actions@github.com" | |
git config user.name "GitHub Actions" | |
npm --no-git-tag-version version ${DEFOLD_VERSION} | |
git add --all | |
git commit -m "chore: bump version to ${DEFOLD_VERSION}" | |
git push | |
fi | |
- name: Build | |
continue-on-error: true | |
run: | | |
if [ "${DEFOLD_VERSION}" == "${PACKAGE_VERSION}" ]; then | |
echo "${DEFOLD_VERSION} already exists. Skipping build." | |
exit 0 | |
else | |
# Build | |
yarn | |
yarn run build | |
git add --all | |
git commit -m "feat: build for Defold stable ${DEFOLD_VERSION}" | |
git push | |
fi | |
- name: Publish Tag and Release | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
if [ "${DEFOLD_VERSION}" == "${PACKAGE_VERSION}" ]; then | |
echo "${DEFOLD_VERSION} already exists. Skipping publish." | |
exit 0 | |
else | |
# Create Tag | |
GITHUB_VERSION="v${DEFOLD_VERSION}" | |
git tag ${GITHUB_VERSION} | |
git push origin ${GITHUB_VERSION} | |
# Create Release | |
gh release create ${GITHUB_VERSION} -t "${GITHUB_VERSION}" -n "Release for Defold ${GITHUB_VERSION}" | |
fi |