|
| 1 | +name: Release UI Bundle |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - 'main' |
| 7 | + |
| 8 | +jobs: |
| 9 | + bundle-release: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Configure Git Credentials |
| 14 | + uses: de-vri-es/setup-git-credentials@v2 |
| 15 | + with: |
| 16 | + credentials: ${{ secrets.GIT_CREDENTIALS }} |
| 17 | + |
| 18 | + - name: Checkout Repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + fetch-depth: 0 # fetch tags too |
| 22 | + |
| 23 | + - name: Check Last Commit Message |
| 24 | + id: skip_release |
| 25 | + env: |
| 26 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 27 | + run: | |
| 28 | + last_commit_message=$(git log -1 --pretty=%B) |
| 29 | + if [[ $last_commit_message == *"[no-release]"* ]]; then |
| 30 | + echo "Last commit message contains [no-release]. Skipping workflow." |
| 31 | + echo "skip_release=1" >> $GITHUB_OUTPUT |
| 32 | + fi |
| 33 | +
|
| 34 | + - name: Setup Node.js |
| 35 | + if: ${{ steps.skip_release.outputs.skip_release == '' }} |
| 36 | + uses: actions/setup-node@v4 |
| 37 | + with: |
| 38 | + node-version: 21.6.1 |
| 39 | + |
| 40 | + - name: Install Dependencies |
| 41 | + if: ${{ steps.skip_release.outputs.skip_release == '' }} |
| 42 | + run: npm ci |
| 43 | + |
| 44 | + - name: Build UI Bundle |
| 45 | + if: ${{ steps.skip_release.outputs.skip_release == '' }} |
| 46 | + run: | |
| 47 | + set -o pipefail |
| 48 | + gulp bundle |& tee $GITHUB_WORKSPACE/build.log |
| 49 | +
|
| 50 | + - name: Get Latest Release Tag |
| 51 | + id: get_latest_tag |
| 52 | + if: ${{ steps.skip_release.outputs.skip_release == '' }} |
| 53 | + run: | |
| 54 | + latest_tag=$(git describe --tags --abbrev=0) |
| 55 | + echo "tag=$latest_tag" >> $GITHUB_OUTPUT |
| 56 | +
|
| 57 | + - name: Extract Tag Integer |
| 58 | + id: extract_tag_integer |
| 59 | + if: ${{ steps.skip_release.outputs.skip_release == '' }} |
| 60 | + run: | |
| 61 | + parsed_tag=${{ steps.get_latest_tag.outputs.tag }} |
| 62 | + tag_integer=$(echo $parsed_tag | grep -oE '[0-9]+') |
| 63 | + echo "tag_integer=$tag_integer" >> $GITHUB_OUTPUT |
| 64 | +
|
| 65 | + - name: Increment Tag |
| 66 | + id: increment_tag |
| 67 | + if: ${{ steps.skip_release.outputs.skip_release == '' }} |
| 68 | + run: | |
| 69 | + current_tag_integer=${{ steps.extract_tag_integer.outputs.tag_integer }} |
| 70 | + next_tag_integer=$((current_tag_integer + 1)) |
| 71 | + next_tag="prod-$next_tag_integer" |
| 72 | + echo "next_tag=$next_tag" >> $GITHUB_OUTPUT |
| 73 | +
|
| 74 | + - name: Create Release |
| 75 | + if: ${{ steps.skip_release.outputs.skip_release == '' }} |
| 76 | + env: |
| 77 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + tag: ${{ steps.increment_tag.outputs.next_tag }} |
| 79 | + run: | |
| 80 | + gh release create "$tag" build/ui-bundle.zip \ |
| 81 | + --repo="$GITHUB_REPOSITORY" \ |
| 82 | + --title=$tag \ |
| 83 | + --generate-notes |
0 commit comments