-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (115 loc) · 4.35 KB
/
package-linux.yml
File metadata and controls
137 lines (115 loc) · 4.35 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
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
name: package-linux
on:
workflow_dispatch:
inputs:
git_ref:
description: Git ref to build, such as main or v0.1.0
required: true
default: main
run_tests:
description: Set to false to skip tests for older tags that are packaging-only
required: true
default: true
version:
description: Optional version override for Linux package names
required: false
release_tag:
description: Optional existing release tag to receive the Linux assets
required: false
release:
types:
- published
permissions:
contents: write
jobs:
package-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.git_ref || github.event.release.tag_name }}
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
- name: Resolve packaging metadata
shell: bash
run: |
set -euo pipefail
source ./scripts/packaging-metadata.sh
initialize_packaging_metadata "$PWD"
repo_version="$(get_repo_version)"
if [[ '${{ github.event_name }}' == 'release' ]]; then
git_ref='${{ github.event.release.tag_name }}'
version_input=''
release_tag_input='${{ github.event.release.tag_name }}'
else
git_ref='${{ inputs.git_ref }}'
version_input='${{ inputs.version }}'
release_tag_input='${{ inputs.release_tag }}'
fi
if [[ -n "${version_input}" ]]; then
resolved_version="${version_input}"
elif [[ "${git_ref}" == v* ]]; then
resolved_version="${git_ref#v}"
else
resolved_version="${repo_version}"
fi
if [[ -z "${resolved_version}" ]]; then
echo "Unable to resolve Linux package version." >&2
exit 1
fi
{
echo "TOKENMAP_LINUX_VERSION=${resolved_version}"
echo "TOKENMAP_LINUX_RELEASE_TAG=${release_tag_input}"
} >> "${GITHUB_ENV}"
- name: Restore
run: dotnet restore Clever.TokenMap.sln
- name: Build
run: dotnet build Clever.TokenMap.sln --no-restore
- name: Test
if: github.event_name != 'workflow_dispatch' || inputs.run_tests != 'false'
run: dotnet test Clever.TokenMap.sln --no-build
- name: Package Linux artifacts
env:
PACKAGE_VERSION: ${{ env.TOKENMAP_LINUX_VERSION }}
PUBLISH_OUTPUT_ROOT: .artifacts/linux-package-inputs/publish
run: bash ./scripts/package-linux.sh
- name: Resolve Linux artifact paths
shell: bash
run: |
set -euo pipefail
deb_path="$(find .artifacts/linux-x64 -maxdepth 1 -type f -name '*.deb' | head -n 1)"
portable_path="$(find .artifacts/linux-x64 -maxdepth 1 -type f -name '*.tar.gz' | head -n 1)"
if [[ -z "${deb_path}" || -z "${portable_path}" ]]; then
echo "Expected Linux package artifacts were not found." >&2
exit 1
fi
deb_name="$(basename "${deb_path}")"
portable_name="$(basename "${portable_path}")"
artifact_upload_name="${deb_name%.deb}"
{
echo "TOKENMAP_LINUX_DEB_PATH=${deb_path}"
echo "TOKENMAP_LINUX_DEB_NAME=${deb_name}"
echo "TOKENMAP_LINUX_PORTABLE_PATH=${portable_path}"
echo "TOKENMAP_LINUX_PORTABLE_NAME=${portable_name}"
echo "TOKENMAP_LINUX_ARTIFACT_BASE_NAME=${artifact_upload_name}"
} >> "${GITHUB_ENV}"
- name: Upload Linux workflow artifact
uses: actions/upload-artifact@v6
with:
name: ${{ env.TOKENMAP_LINUX_ARTIFACT_BASE_NAME }}
path: |
${{ env.TOKENMAP_LINUX_DEB_PATH }}
${{ env.TOKENMAP_LINUX_PORTABLE_PATH }}
if-no-files-found: error
- name: Attach Linux artifacts to GitHub release
if: env.TOKENMAP_LINUX_RELEASE_TAG != ''
run: |
gh release upload "${{ env.TOKENMAP_LINUX_RELEASE_TAG }}" \
"${{ env.TOKENMAP_LINUX_DEB_PATH }}" \
"${{ env.TOKENMAP_LINUX_PORTABLE_PATH }}" \
--clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}