forked from overextended/ox_lib
-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (92 loc) · 3.24 KB
/
release.yml
File metadata and controls
105 lines (92 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Release
on:
push:
branches:
- main
workflow_dispatch:
inputs:
version:
description: 'Version to release'
required: true
jobs:
check-commit-message:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Extract version from commit message
id: extract-version
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
VERSION_REGEX='^v[0-9]+\.[0-9]+\.[0-9]+$'
VERSION=$(git log --format=%B -n 1 HEAD | grep -oP "$VERSION_REGEX")
if [[ $VERSION == "" ]]; then
echo "Version not found in commit message."
exit 1
fi
echo "Version: $VERSION"
echo "::set-output name=version::$VERSION"
fi
- name: Set version from workflow dispatch
id: set-version
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "::set-output name=version::${{ github.event.inputs.version }}"
fi
outputs:
version: ${{ steps.extract-version.outputs.version || steps.set-version.outputs.version }}
create-release:
name: Build and Create Tagged Release
runs-on: ubuntu-latest
needs: check-commit-message
steps:
- name: Install archive tools
run: sudo apt install zip
- name: Checkout source code
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.repository.default_branch }}
- name: Set env
run: echo "RELEASE_VERSION=${{ needs.check-commit-message.outputs.version }}" >> $GITHUB_ENV
- name: Bump manifest version
run: node .github/actions/bump-manifest-version.js
env:
TGT_RELEASE_VERSION: ${{ needs.check-commit-message.outputs.version }}
- name: Push manifest change
uses: EndBug/add-and-commit@v8
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 ${{ needs.check-commit-message.outputs.version }}"
- name: Update tag ref
uses: EndBug/latest-tag@latest
with:
tag-name: ${{ needs.check-commit-message.outputs.version }}
- name: Bundle files
run: |
mkdir -p ./temp/ps_lib
mkdir -p ./temp/ps_lib/web/
cp ./{LICENSE,README.md,fxmanifest.lua,init.lua} ./temp/ps_lib
cp -r ./{imports,resource,locales} ./temp/ps_lib
cp -r ./web/build ./temp/ps_lib/web/
cd ./temp && zip -r ../ps_lib.zip ./ps_lib
- name: Create Release
uses: "marvinpinto/action-automatic-releases@v1.2.1"
id: auto_release
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ env.RELEASE_VERSION }}
title: ${{ env.RELEASE_VERSION }}
prerelease: false
files: ps_lib.zip
- name: Publish npm package
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
package: './package/package.json'
access: 'public'