From 186a33472504a81d301eb95a677bc5099225e458 Mon Sep 17 00:00:00 2001 From: Johan Compagner Date: Fri, 20 Dec 2024 14:42:05 +0100 Subject: [PATCH] Create buildDraftRelease.yml --- .github/workflows/buildDraftRelease.yml | 80 +++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 .github/workflows/buildDraftRelease.yml diff --git a/.github/workflows/buildDraftRelease.yml b/.github/workflows/buildDraftRelease.yml new file mode 100644 index 0000000..b2ccc76 --- /dev/null +++ b/.github/workflows/buildDraftRelease.yml @@ -0,0 +1,80 @@ +name: Build and draft release Servoy Component + +on: + push: + branches: + - master + - 20** + - v20** + workflow_dispatch: + workflow_call: + create: + branches: + - 20** + - v20** + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Find component directory + id: find_component_dir + run: echo "COMPONENT_DIR=$(find . -type d -name 'META-INF' -exec dirname {} \;)" >> $GITHUB_ENV + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '22.x' + cache: 'npm' + cache-dependency-path: ${{ env.COMPONENT_DIR }}/package-lock.json + + - name: Install and build component + working-directory: ${{ env.COMPONENT_DIR }} + run: | + npm install + npm run make_release + + - name: Extract version number + uses: nyaa8/package-version@v1.0.3 + with: + path: ${{ env.COMPONENT_DIR }}/package.json + + - name: Get branch name + run: echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV + + - name: Check if release exists and is prerelease + id: check_release + run: | + if gh release view "_${{ env.BRANCH_NAME }}" --json isPrerelease --jq '.isPrerelease'; then + echo "release_exists=true" >> $GITHUB_ENV + else + echo "release_exists=false" >> $GITHUB_ENV + fi + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Delete Prerelease release & Tag + if: env.release_exists == 'true' + run: | + gh release delete _${{ env.BRANCH_NAME }} --cleanup-tag --yes + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create release + run: | + gh release create "_${{ github.ref_name }}" --target "${{ env.BRANCH_NAME }}" --prerelease --title "Nighlty Build ${{ env.BRANCH_NAME }}" --notes "Nightly build. Branch: ${{ env.BRANCH_NAME }} Commit: ${{ github.sha }} Package Version: ${{ env.PACKAGE_VERSION }}" + echo "release_exists=true" >> $GITHUB_ENV + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload assets + if: env.release_exists == 'true' + run: | + gh release upload "_${{ env.BRANCH_NAME }}" ${{ env.COMPONENT_DIR }}/*.zip + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}