From f544c3a60998a01ead82f7277a288ee0d1211587 Mon Sep 17 00:00:00 2001 From: Gellipapa Date: Tue, 16 Jan 2024 23:18:37 +0100 Subject: [PATCH] Update release.yml --- .github/workflows/release.yml | 71 +++++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c6d2af5..2a5f8ea 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Release GitHub Actions With Some Inputs +name: Simple Release GitHub Actions on: workflow_call: @@ -12,7 +12,11 @@ on: description: Given release zip name required: true web: - type: boolean + type: string + description: If the value is true then it builds web files, if not then it is a simple release. + required: false + versionNumber: + type: string description: If the value is true then it builds web files, if not then it is a simple release. required: false jobs: @@ -21,6 +25,13 @@ jobs: runs-on: ubuntu-latest steps: + - name: Convert 'web' input to boolean and set as env var + run: | + if [ "${{ inputs.web }}" = "true" ]; then + echo "WEB=true" >> $GITHUB_ENV + else + echo "WEB=" >> $GITHUB_ENV + fi - name: Install archive tools run: sudo apt install zip @@ -30,28 +41,58 @@ jobs: fetch-depth: 0 ref: ${{ github.event.repository.default_branch }} - - name: 'Setup node' + - name: Setup node uses: actions/setup-node@v3 with: node-version: 17 + + - name: Setup node with dependency path + if: ${{ env.WEB }} + uses: actions/setup-node@v3 + with: + node-version: 17 + cache: 'npm' + cache-dependency-path: web/package-lock.json - name: Install dependencies - if: inputs.web + if: ${{ env.WEB }} run: npm i working-directory: web - name: Run build - if: inputs.web + if: ${{ env.WEB }} run: npm run build working-directory: web env: CI: false - - - name: Download Bump manifest version js file and run in node + + - name: Get Previous tag + id: previoustag + uses: "WyriHaximus/github-action-get-previous-tag@v1" + with: + fallback: 1.0.0 + - name: Get next minor version + id: semvers + uses: "WyriHaximus/github-action-next-semvers@v1" + with: + version: ${{ steps.previoustag.outputs.tag }} + - name: Create new milestone + id: createmilestone + uses: "WyriHaximus/github-action-create-milestone@v1" + with: + title: ${{ steps.semvers.outputs.patch }} + - name: Set Release Version + id: set_version + run: | + if [ "${{ inputs.versionNumber }}" != "" ]; then + echo "DETERMINED_VERSION=${{ inputs.versionNumber }}" >> $GITHUB_ENV + else + echo "DETERMINED_VERSION=${{ steps.semvers.outputs.patch }}" >> $GITHUB_ENV + fi + - name: 'Download Bump manifest version js file and run in node' run: curl -f https://raw.githubusercontent.com/CommunityRP-FiveM-Server/.github/961b50cd10fdda968a7a8a4b78af5fd2447cf650/.github/actions/bump-manifest-version.js | node - env: - TGT_RELEASE_VERSION: ${{ github.ref_name }} - + TGT_RELEASE_VERSION: ${{ env.DETERMINED_VERSION }} - name: Push manifest change uses: EndBug/add-and-commit@v8 with: @@ -59,12 +100,12 @@ jobs: push: true author_name: Manifest Bumper author_email: 41898282+github-actions[bot]@users.noreply.github.com - message: 'chore: bump manifest version to ${{ github.ref_name }}' + message: 'chore: bump manifest version to ${{ env.DETERMINED_VERSION }}' - name: Update tag ref uses: EndBug/latest-tag@latest with: - tag-name: ${{ github.ref_name }} + tag-name: ${{ env.DETERMINED_VERSION }} - name: Create exclude file from input run: | @@ -74,7 +115,7 @@ jobs: done - name: Bundle web files - if: inputs.web + if: ${{ env.WEB }} run: | mkdir -p ./temp/${{ inputs.zipName }} mkdir -p ./temp/${{ inputs.zipName }}/web @@ -85,8 +126,8 @@ jobs: mkdir -p ./temp/${{ inputs.zipName }} if [[ -f exclude.txt ]]; then - rsync -av --progress --exclude=temp/ --exclude-from=exclude.txt --exclude=exclude.txt ./ ./temp/${{ inputs.zipName }}/ - elif [[ "${{ inputs.web }}" == "true" ]]; then + rsync -av --progress --exclude=temp/ --exclude-from=exclude.txt --exclude=exclude.txt --exclude=.git --exclude=.github ./ ./temp/${{ inputs.zipName }}/ + elif [[ "${{ env.WEB }}" == "true" ]]; then rsync -av --progress --exclude=temp/ --exclude=.git --exclude=.github --include=web/dist/** --exclude=web/** ./ ./temp/${{ inputs.zipName }}/ else rsync -av --progress --exclude=temp/ --exclude=.git --exclude=.github ./ ./temp/${{ inputs.zipName }}/ @@ -99,7 +140,7 @@ jobs: id: auto_release with: repo_token: '${{ secrets.GITHUB_TOKEN }}' - title: '${{ env.RELEASE_VERSION }}' + automatic_release_tag: ${{ env.DETERMINED_VERSION }} prerelease: false files: ${{ inputs.zipName }}.zip