Skip to content

Create Release

Create Release #4

name: Create Release
on:
workflow_dispatch:
branches:
- main
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check out Repository
uses: actions/checkout@v4
- name: CubeSQLPlugin Version
run: |
CUBESQLPLUGIN_VERSION=$(grep -o "#define PLUGIN_VERSION.*" sources/CubeSQLPlugin.h | awk -F'"' '{print $2}')
echo "CubeSQLPlugin Version: $CUBESQLPLUGIN_VERSION"
echo "CUBESQLPLUGIN_VERSION=$CUBESQLPLUGIN_VERSION" >> $GITHUB_ENV
- name: Check Release Version Tag
id: github-tag
uses: actions/github-script@v7
with:
script: |
try {
console.log('Check: Expect that Tag ${{ env.CUBESQLPLUGIN_VERSION }} does not exist');
const getRefResponse = await github.rest.git.getRef({
owner: context.repo.owner,
ref: "tags/${{ env.CUBESQLPLUGIN_VERSION }}",
repo: context.repo.repo,
});
// console.log(getRefResponse);
if (getRefResponse.status === 200) {
console.log('Tag ${{ env.CUBESQLPLUGIN_VERSION }} exists');
core.setFailed('Tag ${{ env.CUBESQLPLUGIN_VERSION }} already exists. CubeSQLPlugin Version needs to be changed.');
} else {
console.log('Tag ${{ env.CUBESQLPLUGIN_VERSION }} does not exist');
}
} catch(error) {
console.log('Tag ${{ env.CUBESQLPLUGIN_VERSION }} does not exist');
}
- name: Create Release as Draft
run: |
gh release create ${{ env.CUBESQLPLUGIN_VERSION }} --generate-notes --draft=true
- name: Wait until Draft Release is available
shell: bash {0}
run: |
for i in {1..10}
do
gh release view ${{ env.CUBESQLPLUGIN_VERSION }}
if [ $? -eq 0 ]; then
echo "Draft Release is ready"
exit 0
fi
echo "Draft Release is not ready yet"
sleep 1
done
echo "Draft Release not found in 10 attempts"
exit 1
- name: Upload CubeSQLPlugin.xojo_plugin as Release Asset
run: |
gh release upload ${{ env.CUBESQLPLUGIN_VERSION }} ./CubeSQLPlugin.xojo_plugin
- name: Publish Release
run: |
gh release edit ${{ env.CUBESQLPLUGIN_VERSION }} --draft=false
- name: Delete Release in case of a failure
if: ${{ failure() }}
run: |
gh release delete ${{ env.CUBESQLPLUGIN_VERSION }} --yes