forked from performous/performous
-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (131 loc) · 5.65 KB
/
build_and_release.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Build and Release Performous
# Controls when the workflow will run
on:
# Run on a schedule to get weekly updates for the Linux containers
# and keep the cache fresh for Windows builds. Runs Sundays at midnight.
schedule:
- cron: "0 0 * * 0"
# Triggers the workflow on merges to master, release branches,
# all PRs, and release tags
push:
branches:
- master
- '[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+'
tags:
- '[0-9]+\.[0-9]+\.[0-9]+'
- '[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+'
# On anything pull request related
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Note: entire jobs or sections can be disabled by adding
# if: ${{ false }} to the definition column
jobs:
# Determine version
determine_version:
name: Determine the version to be used
runs-on: ubuntu-latest
outputs:
latest_tag_version: ${{ steps.versioning.outputs.latest_tag_version }}
latest_full_tag_version: ${{ steps.versioning.outputs.latest_full_tag_version }}
version_major: ${{ steps.versioning.outputs.version_major }}
version_minor: ${{ steps.versioning.outputs.version_minor }}
version_patch: ${{ steps.versioning.outputs.version_patch }}
version_tweak: ${{ steps.versioning.outputs.version_tweak }}
complete_version: ${{ steps.versioning.outputs.complete_version }}
steps:
- name: Checkout Performous
uses: actions/checkout@v4
with:
path: ${{ github.workspace }}/performous
repository: ${{ github.event.repository.full_name }}
ref: '${{ github.event.head.ref }}'
fetch-depth: 0
- name: Determine the complete version
id: versioning
run: |
# Always check the tags on master since it will have the latest.
# Tags will trigger their own workflow and version names
cd performous
LATEST_TAG_VERSION=$(git describe --tags --abbrev=0 || echo 1.0.0)
LATEST_FULL_TAG_VERSION=$(git describe --tags || echo 1.0.0)
echo "latest_tag_version=$(git describe --tags --abbrev=0 || echo 1.0.0)" >> $GITHUB_OUTPUT
echo "latest_full_tag_version=$(git describe --tags || echo 1.0.0)" >> $GITHUB_OUTPUT
echo "version_major=$(cut -d '.' -f 1 <<< $(git describe --tags --abbrev=0 || echo 1.0.0))" >> $GITHUB_OUTPUT
echo "version_minor=$(cut -d '.' -f 2 <<< $(git describe --tags --abbrev=0 || echo 1.0.0))" >> $GITHUB_OUTPUT
echo "version_patch=$(cut -d '.' -f 3 <<< $(git describe --tags --abbrev=0 || echo 1.0.0))" >> $GITHUB_OUTPUT
echo "version_tweak=0" >> $GITHUB_OUTPUT
if [[ ${{ github.event_name }} == "push" ]]; then
COMMIT_SHA=$(git rev-parse --short=7 ${{ github.event.after }})
elif [[ ${{ github.event_name }} == "pull_request" ]]; then
COMMIT_SHA=$(git rev-parse --short=7 ${{ github.event.pull_request.head.sha }})
fi
if [[ ${{ github.ref_type }} == "tag" ]]; then
echo "complete_version=${{github.ref_name}}" >> $GITHUB_OUTPUT
elif [[ ${{ github.ref_type }} == "branch" ]]; then
if [[ ${{ github.ref_name}} == "master" ]]; then
NUMCOMMITS=$(git describe --tags | sed "s|$(git describe --tags --abbrev=0)-||" | cut -d- -f1)
echo "complete_version=$LATEST_TAG_VERSION+${NUMCOMMITS}-git-${COMMIT_SHA}" >> $GITHUB_OUTPUT
else
echo "complete_version=$LATEST_TAG_VERSION+git-${COMMIT_SHA}-PR${{github.event.pull_request.number}}-alpha" >> $GITHUB_OUTPUT
fi
fi
# Set up a release that packages will be published to.
create_release:
name: Create a release
runs-on: ubuntu-latest
# Make sure the output variable for this step is set so it
# can be consumed by later build steps
outputs:
release_id: ${{ steps.create_release.outputs.id }}
steps:
- name: Create the Main release
id: create_release
if: ${{ github.event_name != 'pull_request' && github.ref_type == 'tag' }}
uses: softprops/[email protected]
with:
tag_name: ${{ github.ref_name }}
name: Performous ${{ github.ref_name }}
draft: true
prerelease: false
# Pull in the Linux build workflow
Linux_Packages:
name: Build the Linux packages
uses: ./.github/workflows/linux.yml
with:
package_complete_version: ${{ needs.determine_version.outputs.complete_version }}
release_id: ${{ needs.create_release.outputs.release_id }}
needs:
- determine_version
- create_release
# Pull in the AppImage build workflow
AppImage_Package:
name: Build the AppImage package
uses: ./.github/workflows/appimage.yml
with:
package_complete_version: ${{ needs.determine_version.outputs.complete_version }}
release_id: ${{ needs.create_release.outputs.release_id }}
needs:
- determine_version
- create_release
# Pull in the MacOS build workflow
MacOS_Package:
name: Build the MacOS package
uses: ./.github/workflows/macos.yml
secrets: inherit
with:
package_complete_version: ${{ needs.determine_version.outputs.complete_version }}
release_id: ${{ needs.create_release.outputs.release_id }}
needs:
- determine_version
- create_release
# Pull in the Windows build workflow
Windows_Packages:
name: Build the Windows packages
uses: ./.github/workflows/windows.yml
with:
package_complete_version: ${{ needs.determine_version.outputs.complete_version }}
release_id: ${{ needs.create_release.outputs.release_id }}
needs:
- determine_version
- create_release