-
Notifications
You must be signed in to change notification settings - Fork 8
168 lines (135 loc) · 5.1 KB
/
checkTlsClient.yml
File metadata and controls
168 lines (135 loc) · 5.1 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Check tls-client version
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
permissions:
contents: write
jobs:
check-tls-client-version:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install dependencies
run: |
pwd
sudo apt-get update
sudo apt-get install -y jq gh tree
- name: Get latest release info
id: get_latest
run: |
RELEASE_JSON=$(curl -s https://api.github.com/repos/bogdanfinn/tls-client/releases/latest)
TAG_NAME=$(echo "$RELEASE_JSON" | jq -r '.tag_name')
echo "Latest tag: $TAG_NAME"
echo "LATEST_TAG=$TAG_NAME" >> $GITHUB_ENV
- name: Check if new version
id: check_version
run: |
if [ -f "./tls-client-version.txt" ]; then
LAST_VERSION=$(cat ./tls-client-version.txt)
else
LAST_VERSION=""
fi
echo "Last processed version: $LAST_VERSION"
if [ "$LAST_VERSION" = "${{ env.LATEST_TAG }}" ]; then
echo "Already up to date. Exiting."
echo "SHOULD_CONTINUE=false" >> $GITHUB_ENV
else
echo "New version found: ${{ env.LATEST_TAG }}"
echo "SHOULD_CONTINUE=true" >> $GITHUB_ENV
fi
- name: Download tls-client libraries
if: env.SHOULD_CONTINUE == 'true'
run: |
# Create temp directory for downloads
mkdir -p build/temp
# Use the already fetched latest release info
echo "Downloading assets from latest release: ${{ env.LATEST_TAG }}"
# Get assets for the latest release using GitHub CLI
assets=$(gh release view ${{ env.LATEST_TAG }} --repo bogdanfinn/tls-client --json assets -q '.assets[].name' | grep -v "xgo")
for asset in $assets; do
echo "Downloading $asset..."
# Download the asset directly using GitHub CLI
gh release download ${{ env.LATEST_TAG }} --repo bogdanfinn/tls-client --pattern "$asset" --dir build/temp
if [ $? -eq 0 ]; then
echo "Downloaded $asset successfully"
else
echo "Failed to download $asset"
fi
done
# List downloaded files
echo "Downloaded files in build/temp:"
ls -la build/temp/
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update version file
if: env.SHOULD_CONTINUE == 'true'
run: |
echo "${{ env.LATEST_TAG }}" > tls-client-version.txt
echo "Updated version file to ${{ env.LATEST_TAG }}"
- name: Setup Node.js
if: env.SHOULD_CONTINUE == 'true'
uses: actions/setup-node@v4.4.0
with:
node-version: 'latest'
- name: Run native-builder script
if: env.SHOULD_CONTINUE == 'true'
run: |
# Pass the version to the Node.js script via environment variable
export TLS_CLIENT_VERSION="${{ env.LATEST_TAG }}"
# Run the prepare script
cd build/native-builder
npm install
npm run prepare-libraries
echo "Native libraries preparation completed"
# Return to root directory
cd ../..
# Remove template directory after projects are generated
rm -rf src/native/template
- name: Setup .NET
if: env.SHOULD_CONTINUE == 'true'
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Pack and publish native projects to NuGet
if: env.SHOULD_CONTINUE == 'true'
run: |
# Extract version number from LATEST_TAG (remove 'v' prefix)
VERSION="${{ env.LATEST_TAG }}"
if [[ "$VERSION" == v* ]]; then
VERSION="${VERSION#v}"
fi
echo "Using version: $VERSION for all native packages"
# Create output directory
mkdir -p packages
# Find all .csproj files in native directories
for project in src/native/TlsClient.Native.*/*.csproj; do
echo "Packing project: $project"
# Pack the project with the extracted version
dotnet pack "$project" -c Release -p:Version=$VERSION --output packages
if [ $? -ne 0 ]; then
echo "Warning: Packaging failed for $project"
continue
fi
# Get the package name from the project file name
package_name=$(basename "$project" .csproj)
package_path="packages/$package_name.$VERSION.nupkg"
if [ -f "$package_path" ]; then
# Push to NuGet
echo "Publishing package: $package_path"
dotnet nuget push "$package_path" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
else
echo "Warning: Package not found at $package_path"
fi
done
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
- name: Commit and push changes
if: env.SHOULD_CONTINUE == 'true'
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git add tls-client-version.txt
git commit -m "Update tls-client version to ${{ env.LATEST_TAG }}"
git push