|
| 1 | +name: Build and draft release Servoy Component |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - 20** |
| 8 | + - v20** |
| 9 | + workflow_dispatch: |
| 10 | + workflow_call: |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Find component directory |
| 22 | + id: find_component_dir |
| 23 | + run: echo "COMPONENT_DIR=$(find . -type d -name 'META-INF' -exec dirname {} \;)" >> $GITHUB_ENV |
| 24 | + |
| 25 | + - name: Use Node.js |
| 26 | + uses: actions/setup-node@v4 |
| 27 | + with: |
| 28 | + node-version: '22.x' |
| 29 | + cache: 'npm' |
| 30 | + |
| 31 | + - name: Cache + Restore node_modules |
| 32 | + uses: actions/cache@v4 |
| 33 | + with: |
| 34 | + # Cache node_modules and Puppeteer chrome |
| 35 | + path: | |
| 36 | + ~/.cache |
| 37 | + .angular |
| 38 | + node_modules |
| 39 | + key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }} |
| 40 | + restore-keys: | |
| 41 | + ${{ runner.os }}-node_modules- |
| 42 | +
|
| 43 | + - name: Install and build component |
| 44 | + working-directory: ${{ env.COMPONENT_DIR }} |
| 45 | + run: | |
| 46 | + npm install |
| 47 | + npm run make_release |
| 48 | +
|
| 49 | + - name: Extract version number |
| 50 | + uses: nyaa8/package-version@v1.0.3 |
| 51 | + with: |
| 52 | + path: ${{ env.COMPONENT_DIR }}/package.json |
| 53 | + |
| 54 | + - name: Get branch name |
| 55 | + run: echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV |
| 56 | + |
| 57 | + - name: Check if release exists and is prerelease |
| 58 | + id: check_release |
| 59 | + run: | |
| 60 | + if gh release view "_${{ env.BRANCH_NAME }}" --json isPrerelease --jq '.isPrerelease'; then |
| 61 | + echo "release_exists=true" >> $GITHUB_ENV |
| 62 | + else |
| 63 | + echo "release_exists=false" >> $GITHUB_ENV |
| 64 | + fi |
| 65 | + env: |
| 66 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + |
| 68 | + - name: Delete Prerelease release & Tag |
| 69 | + if: env.release_exists == 'true' |
| 70 | + run: | |
| 71 | + gh release delete _${{ env.BRANCH_NAME }} --cleanup-tag --yes |
| 72 | + env: |
| 73 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + |
| 75 | + - name: Create release |
| 76 | + run: | |
| 77 | + 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 }}" |
| 78 | + echo "release_exists=true" >> $GITHUB_ENV |
| 79 | + env: |
| 80 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 81 | + |
| 82 | + - name: Upload assets |
| 83 | + if: env.release_exists == 'true' |
| 84 | + run: | |
| 85 | + gh release upload "_${{ env.BRANCH_NAME }}" ${{ env.COMPONENT_DIR }}/*.zip |
| 86 | + env: |
| 87 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments