From d482935e08ab425e17ba17e70f5ac17d42838e27 Mon Sep 17 00:00:00 2001 From: Solareon <769465+solareon@users.noreply.github.com> Date: Tue, 27 Aug 2024 19:51:03 +0200 Subject: [PATCH] feat(github): release action --- .github/workflows/release-action.yml | 111 ++++++++++++++------------- .github/workflows/release.yml | 7 +- 2 files changed, 58 insertions(+), 60 deletions(-) diff --git a/.github/workflows/release-action.yml b/.github/workflows/release-action.yml index e6ed84b..c4a428b 100644 --- a/.github/workflows/release-action.yml +++ b/.github/workflows/release-action.yml @@ -1,63 +1,66 @@ name: "Release Action" on: - push: - tags: - - "v*" - -env: - BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + workflow_run: + workflows: [Create New Release] + types: + - completed jobs: - release-action: - name: "Create Release" - runs-on: "ubuntu-latest" - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.BRANCH_NAME }} + release-action: + name: "Create Release" + runs-on: "ubuntu-latest" + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.repository.default_branch }} + + - name: Get the latest tag + id: get_tag + run: echo "LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_ENV - - name: Install ZIP - run: sudo apt install zip + - name: Install ZIP + run: sudo apt install zip - - name: Install pnpm - uses: pnpm/action-setup@v4.0.0 - with: - version: 9 + - name: Install pnpm + uses: pnpm/action-setup@v4.0.0 + with: + version: 9 - - name: Setup node - uses: actions/setup-node@v4 - with: - node-version: 20.x - cache: "pnpm" - cache-dependency-path: "web/pnpm-lock.yaml" - - - name: Install dependencies - run: pnpm i --frozen-lockfile - working-directory: web - - - name: Run build - run: pnpm build - working-directory: web - env: - CI: false - - - name: Bundle files - run: | - shopt -s extglob - mkdir -p ./temp/${{ github.event.repository.name }} - mkdir -p ./temp/${{ github.event.repository.name }}/web - cp ./{README.md,LICENSE,fxmanifest.lua} ./temp/${{ github.event.repository.name }} - cp -r ./{client,config,server} ./temp/${{ github.event.repository.name }} - cp -r ./web/public ./temp/${{ github.event.repository.name }}/web/public - cd ./temp && zip -r ../${{ github.event.repository.name }}.zip ./${{ github.event.repository.name }} + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: 20.x + cache: "pnpm" + cache-dependency-path: "web/pnpm-lock.yaml" + + - name: Install dependencies + run: pnpm i --frozen-lockfile + working-directory: web + + - name: Run build + run: pnpm build + working-directory: web + env: + CI: false + + - name: Bundle files + run: | + shopt -s extglob + mkdir -p ./temp/${{ github.event.repository.name }} + mkdir -p ./temp/${{ github.event.repository.name }}/web + cp ./{README.md,LICENSE,config.lua,fxmanifest.lua} ./temp/${{ github.event.repository.name }} + cp -r ./{client,locales,server} ./temp/${{ github.event.repository.name }} + cp -r ./web/public ./temp/${{ github.event.repository.name }}/web/public + cd ./temp && zip -r ../${{ github.event.repository.name }}.zip ./${{ github.event.repository.name }} - - name: Create Release - uses: marvinpinto/action-automatic-releases@latest - with: - title: ${{ github.ref_name }} - repo_token: "${{ secrets.GITHUB_TOKEN }}" - prerelease: false - files: ${{ github.event.repository.name }}.zip + - name: Create Release + uses: marvinpinto/action-automatic-releases@latest + with: + title: ${{ env.LATEST_TAG }} + repo_token: '${{ secrets.GITHUB_TOKEN }}' + prerelease: false + automatic_release_tag: ${{ env.LATEST_TAG }} + files: ${{ github.event.repository.name }}.zip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 74f3f00..f1c8a21 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,6 @@ jobs: name: Create New Release runs-on: ubuntu-latest steps: - - name: Checkout Repository uses: actions/checkout@v4 with: @@ -33,8 +32,4 @@ jobs: add: fxmanifest.lua push: true message: 'chore: bump manifest version to ${{ inputs.version }}' - - - name: Push Git Tag - run: | - git tag ${{ inputs.version }} - git push origin ${{ inputs.version }} + tag: ${{ inputs.version }}