Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
chore(release): add GitHub automatic releases
Browse files Browse the repository at this point in the history
  • Loading branch information
swkeep committed May 14, 2023
1 parent 1038eac commit 72f099a
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/actions/version.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const fs = require('fs');

const version = process.env.RELEASE_VERSION;
const newVersion = version.replace('v', '');

try {
let manifestFile = fs.readFileSync('fxmanifest.lua', 'utf8');
const newFileContent = manifestFile.replace(/\bversion\s+(.*)$/gm, `version '${newVersion}'`);
fs.writeFileSync('fxmanifest.lua', newFileContent);
} catch (err) {
console.error(err);
}
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Release

on:
push:
tags:
- "v*.*.*"

jobs:
create-release:
name: Build and Create Tagged Release
runs-on: ubuntu-latest
steps:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16.x

- name: Checkout source code
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.repository.default_branch }}

- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Bump manifest version
run: node .github/actions/version.cjs
env:
RELEASE_VERSION: ${{ github.ref_name }}

- name: Push manifest change
uses: EndBug/add-and-commit@v9
with:
add: fxmanifest.lua
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 }}"

- name: Update tag ref
uses: EndBug/latest-tag@latest
with:
tag-name: ${{ github.ref_name }}

- name: Bundle files
run: |
mkdir -p ./temp
cp ./{LICENSE,README.md,fxmanifest.lua,config.lua} ./temp
cp -r ./client ./temp/client
cp -r ./inventoryimages ./temp/inventoryimages
cp -r ./locale ./temp/locale
cp -r ./server ./temp/server
cp -r ./shared ./temp/shared
- name: Zip files
run: |
cd ./temp && zip -r ../${{ github.event.repository.name }}.zip ./
- name: Create Release
uses: "marvinpinto/action-automatic-releases@v1.2.1"
id: auto_release
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
files: ${{ github.event.repository.name }}.zip
title: ${{ env.RELEASE_VERSION }}
prerelease: false

env:
CI: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 72f099a

Please sign in to comment.