Repository navigation
154 lines (142 loc) · 6.54 KB
/
Copy pathdeploy-cpp.yml
File metadata and controls
154 lines (142 loc) · 6.54 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Deploy new cpp version
on:
workflow_call:
inputs:
recipe_folder:
required: true
type: string
secrets:
nuget_token:
required: true
defaults:
run:
working-directory: cpp
jobs:
test:
uses: linksplatform/Workflows/.github/workflows/cpp-test.yml@main
get_package_info:
uses: linksplatform/Workflows/.github/workflows/get-cpp-package-info.yml@main
pushToNuget:
runs-on: ubuntu-latest
needs: [test, get_package_info]
env:
NUSPEC_PATH: $(echo ${{needs.get_package_info.outputs.nuspec_path}} | sed 's~^cpp/~~')
steps:
- uses: actions/checkout@v1
with:
submodules: true
- name: Push to nuget
run: |
sudo apt-get install nuget
echo "needs.get_package_info.outputs.nuspec_path: ${{needs.get_package_info.outputs.nuspec_path}}"
echo "env.NUSPEC_PATH: ${{env.NUSPEC_PATH}}"
echo "needs.get_package_info.outputs.name: ${{needs.get_package_info.outputs.name}}"
echo "needs.get_package_info.outputs.version: ${{needs.get_package_info.outputs.version}}"
nuspec_direction=$(dirname ${{env.NUSPEC_PATH}})
echo "nuspec_direction: ${nuspec_direction}"
# Ensure NuGet package does not exist
NuGetPackageUrl="https://globalcdn.nuget.org/packages/Platform.${{github.event.repository.name}}.TemplateLibrary.${{needs.get_package_info.outputs.version}}.nupkg"
NuGetPackageUrl=$(echo "$NuGetPackageUrl" | tr '[:upper:]' '[:lower:]')
NuGetPageStatus="$(curl -Is "$NuGetPackageUrl" | head -1)"
StatusContents=( $NuGetPageStatus )
if [ "${StatusContents[1]}" == "200" ]; then
echo "NuGet with current version is already pushed."
exit 0
fi
# Download icon.png for the package
wget -O "$nuspec_direction/icon.png" https://raw.githubusercontent.com/linksplatform/Documentation/18469f4d033ee9a5b7b84caab9c585acab2ac519/doc/Avatar-rainbow-icon-64x64.png
# Download TemplateLibrary.targets for the package
wget -O "$nuspec_direction/Platform.${{github.event.repository.name}}.TemplateLibrary.targets" https://raw.githubusercontent.com/linksplatform/Files/ed0dc702f52d56d80ea2f19c93df5cf2fdcbccbf/TemplateLibrary.targets
# Update .nuspec file
IFS=$'\n' #Set Separator.
files=$(find $nuspec_direction | grep "\.h" | grep -v "bin" | grep -v "obj" | cut -c $(( $(echo $nuspec_direction | wc -m) + 1))-)
filename="${{env.NUSPEC_PATH}}"
file=($(cat $filename)) #Read file by line in array
unset file[-1] #Remove last element in array.
file+=(" <files>")
file+=(" <file src=\"icon.png\" target=\"images/icon.png\" />")
file+=(" <file src=\"Platform.${{github.event.repository.name}}.TemplateLibrary.targets\" target=\"build\native\Platform.${{github.event.repository.name}}.TemplateLibrary.targets\" />")
for FILE in $files #Get all files on directory.
do
file+=(" <file src=\"$FILE\" target=\"lib\\native\\include\\$FILE\" />") #Append new files to array.
done
file+=(" </files>") #Append end for tag files.
file+=("</package>") #Append end for tag package.
printf '%s\n' "${file[@]}" > "$filename" #Write array by line to .nuspec file.
# Pack NuGet package by .nuspec file
nuget pack "${{env.NUSPEC_PATH}}"
# Push NuGet package
nuget push ./**/*.nupkg -NoSymbols -Source https://api.nuget.org/v3/index.json -ApiKey "${{secrets.nuget_token}}"
get_conan_package_info:
uses: linksplatform/Workflows/.github/workflows/get-cpp-conan-package-info.yml@main
publishRelease:
runs-on: ubuntu-latest
needs: [test, get_package_info, get_conan_package_info]
env:
artifact_file_name: '${{needs.get_conan_package_info.outputs.name}}_${{needs.get_package_info.outputs.version}}.zip'
tag: "cpp_${{needs.get_package_info.outputs.version}}"
outputs:
artifact_url: 'https://github.com/linksplatform/${{github.event.repository.name}}/releases/${{env.tag}}/download/${{env.artifact_file_name}}'
artifact_sha256: 'https://github.com/linksplatform/${{github.event.repository.name}}/releases/${{env.tag}}/download/${{env.artifact_file_name}}'
steps:
- uses: actions/checkout@v1
with:
submodules: true
- name: Zip conan package
id: zip_conan_package
run: |
zip -r "${{env.artifact_file_name}}" "${{ format('Platform.{0}', github.event.repository.name) }}"
artifact_sha256=$(sha256sum "${{env.artifact_file_name}}" | cut -d " " -f 1)
echo "artifact_sha256=${artifact_sha256}" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1.11.2
with:
tag: "${{env.tag}}"
name: "[C++] ${{needs.get_package_info.outputs.version}}"
body: >
https://www.nuget.org/packages/Platform.${{github.event.repository.name}}.TemplateLibrary/${{needs.get_package_info.outputs.version}}
${{needs.get_package_info.outputs.release_notes}}
artifactErrorsFailBuild: true
artifacts: "cpp/${{env.artifact_file_name}}"
# update_conan_recipe_and_create_pull_request:
# name: Update conan recipe and create pull request
# needs: [publishRelease, get_package_info, get_conan_package_info]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v2
# with:
# submodules: true
# - name: Setup Rust
# uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# toolchain: ${{env.toolchain}}
# components: rustfmt, clippy
# default: true
# - name: Build benchmark
# uses: actions-rs/cargo@v1
# with:
# command: build
# args: --release --all-features
# - name: Run benchmark
# uses: actions-rs/cargo@v1
# with:
# command: bench
# args: --all-features
# run: |
# cargo run ...
# --github-authentication-token=""
# --new-version=""
# --recipe-name=""
# --source-repo-owner-login=""
# --source-repo-name=""
# --source-repo-branch-name=""
# --destination-repo-owner-login=""
# --destination-repo-name=""
# --destination-repo-branch-name=""
# --lib-zip-url=""
# --sha256hash=""
# --dependencies=""
# --previous-version=""