-
-
Notifications
You must be signed in to change notification settings - Fork 36
93 lines (77 loc) · 2.92 KB
/
main.yml
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
name: Build and Release
on:
push:
branches:
- main # Change this to your main branch
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
# Extract previous release version
- name: Extract previous release version
id: extract_previous_version
run: |
previous_tag=$(git describe --abbrev=0 --tags)
previous_version=$(echo "${previous_tag}" | sed 's/V//')
echo "::set-output name=previous_version::${previous_version}"
# Increment version
- name: Increment version
id: increment_version
run: |
major=$(echo "${{ steps.extract_previous_version.outputs.previous_version }}" | cut -d'.' -f1)
minor=$(echo "${{ steps.extract_previous_version.outputs.previous_version }}" | cut -d'.' -f2)
patch=$(echo "${{ steps.extract_previous_version.outputs.previous_version }}" | cut -d'.' -f3)
new_minor=$((minor + 1))
new_version="${major}.${new_minor}.${patch}_beta"
echo "::set-output name=new_version::${new_version}"
# Set new version
- name: Set new version
run: echo "export APP_VERSION=${{ steps.increment_version.outputs.new_version }}" >> $GITHUB_ENV
# Setup Node.js
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
# Set up PHP
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
# Install Composer dependencies
- name: Install Composer dependencies
run: composer install --no-dev --optimize-autoloader
# Install npm dependencies
- name: Install npm dependencies
run: npm install
# Build assets with npm
- name: Build assets with npm
run: npm run build
# Tar project contents with version
- name: Tar project contents with version
run: |
version=${{ steps.increment_version.outputs.new_version }}
tar -czf "project_${version}.tar.gz" .
# Create tag for new version
- name: Create tag for new version
run: git tag -a "v${{ steps.increment_version.outputs.new_version }}" -m "Release v${{ steps.increment_version.outputs.new_version }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Upload tar file to release
- name: Upload tar file to release
uses: actions/upload-artifact@v2
with:
name: project
path: project_*.tar.gz
# Download previous release artifacts
- name: Download previous release artifacts
uses: actions/download-artifact@v2
with:
name: project
path: previous_release
# Copy previous release artifacts to new release
- name: Copy previous release artifacts to new release
run: cp previous_release/* .