Skip to content

Commit

Permalink
Create buildDraftRelease.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
jcompagner authored Dec 20, 2024
1 parent a8d8645 commit 186a334
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/buildDraftRelease.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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 }}

0 comments on commit 186a334

Please sign in to comment.