Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(github): release action #68

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 73 additions & 58 deletions .github/workflows/release-action.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,78 @@
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 }}

- name: Install ZIP
run: sudo apt install zip

- 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: 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
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 tag --sort=-creatordate | head -n 1)" >> $GITHUB_ENV

- name: Install ZIP
run: sudo apt install zip

- 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,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: Update CHANGELOG
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.LATEST_TAG }}
writeToFile: false

- name: Create Release
uses: ncipollo/release-action@v1.14.0
with:
allowUpdates: true
draft: false
makeLatest: true
name: ${{ env.LATEST_TAG }}
tag: ${{ env.LATEST_TAG }}
body: ${{ steps.changelog.outputs.changes }}
artifacts: ${{ github.event.repository.name }}.zip
token: ${{ secrets.GITHUB_TOKEN }}
7 changes: 1 addition & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
name: Create New Release
runs-on: ubuntu-latest
steps:

- name: Checkout Repository
uses: actions/checkout@v4
with:
Expand All @@ -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 }}
Loading