Skip to content

Commit f558a6b

Browse files
committed
workflows: Add automation for choco upgrade
Signed-off-by: Vincent T <vtaylor@microsoft.com>
1 parent 81fb494 commit f558a6b

File tree

2 files changed

+135
-0
lines changed

2 files changed

+135
-0
lines changed
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: PR for updating Chocolatey
2+
3+
# This action will run after a tag starting with "v" is published
4+
# on:
5+
# push:
6+
# tags:
7+
# - 'v*'
8+
# workflow_dispatch:
9+
10+
on:
11+
push:
12+
branches:
13+
- automate-choco-workflow
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
choco-update:
20+
permissions:
21+
contents: write # for Git to git push
22+
pull-requests: write # for creating PRs
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout Headlamp
26+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
27+
with:
28+
token: ${{ secrets.KINVOLK_REPOS_TOKEN }}
29+
# we need the full history for the git tag command, so fetch all the branches
30+
fetch-depth: 0
31+
- name: Configure Git
32+
run: |
33+
user=${{github.actor}}
34+
if [ -z $user ]; then
35+
user=vyncent-t
36+
fi
37+
git config --global user.name "$user"
38+
git config --global user.email "$user@users.noreply.github.com"
39+
# Set up Node.js environment, pay attention to the version
40+
# Some features might not be available in older versions
41+
- name: Create node.js environment
42+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
43+
with:
44+
node-version: '21'
45+
# Install the app dependencies for the choco script
46+
- name: Install app dependencies
47+
run: |
48+
cd $GITHUB_WORKSPACE/app
49+
npm ci
50+
# We set the latest tag as an environment variable before we use it in the next steps
51+
# note that we have to echo the variable to the environment file to make it available in the next steps
52+
- name: Set latest tag
53+
run: |
54+
echo "Setting latest tag"
55+
latestTag=$(git tag --list --sort=version:refname 'v*' | tail -1)
56+
# Remove the 'v' from the tag
57+
latestTag=${latestTag#v}
58+
echo "LATEST_HEADLAMP_TAG=$latestTag" >> $GITHUB_ENV
59+
echo $latestTag
60+
- name: Download checksum
61+
run: |
62+
echo "Downloading checksum"
63+
cd $GITHUB_WORKSPACE/app/windows/chocolatey
64+
curl -L -O "https://github.com/headlamp-k8s/headlamp/releases/download/v$LATEST_HEADLAMP_TAG/checksums.txt"
65+
echo "Checksum downloaded"
66+
if [ -f checksums.txt ]; then
67+
echo "Checksum file exists"
68+
else
69+
echo "Checksum file does not exist"
70+
exit 1
71+
fi
72+
- name: Set hash and checksum
73+
run: |
74+
echo "Setting hash and checksum"
75+
cd $GITHUB_WORKSPACE/app/windows/chocolatey
76+
ls
77+
read -r hash win_file_name <<< $(grep 'win-x64' ./checksums.txt)
78+
echo "Hash: $hash"
79+
echo "Win file name: $win_file_name"
80+
echo "WIN_FILE_NAME=$win_file_name" >> $GITHUB_ENV
81+
echo "WIN_FILE_HASH=$hash" >> $GITHUB_ENV
82+
# Run the choco script
83+
- name: Create nuget package
84+
run: |
85+
echo "Running choco script"
86+
echo "Repository: ${{ github.repository }}"
87+
echo "Workspace: ${GITHUB_WORKSPACE}"
88+
echo $GITHUB_WORKSPACE
89+
pwd
90+
echo "LATEST_HEADLAMP_TAG=$LATEST_HEADLAMP_TAG"
91+
echo "WIN_FILE_HASH=$WIN_FILE_HASH"
92+
echo "creating nuget pkgs"
93+
cd $GITHUB_WORKSPACE/app/windows/chocolatey
94+
./choco-bump.sh $LATEST_HEADLAMP_TAG $WIN_FILE_HASH
95+
echo "Script finished"
96+
echo "Checksum file still exists"
97+
ls
98+
echo "Removing checksums.txt"
99+
rm $GITHUB_WORKSPACE/app/windows/chocolatey/checksums.txt
100+
ls
101+
echo "Checksum file removed"
102+
# REFACTOR FOR CUSTOM NUGET REPO LATER IF NEEDED
103+
- name: Create PR branch and push
104+
run: |
105+
user=${{github.actor}}
106+
if [ -z $user ]; then
107+
user=vyncent-t
108+
fi
109+
echo "Creating PR branch"
110+
echo "Repository: ${{ github.repository }}"
111+
echo "Workspace: ${GITHUB_WORKSPACE}"
112+
pwd
113+
ls
114+
echo echo "https://github.com/headlamp-k8s/headlamp/pull/new/WIP0-choco-update-$LATEST_HEADLAMP_TAG"
115+
git checkout -b "choco-update-$LATEST_HEADLAMP_TAG"
116+
git add .
117+
git commit -s -m "chocolatey: Bump Headlamp version to $LATEST_HEADLAMP_TAG"
118+
git push origin "choco-update-$LATEST_HEADLAMP_TAG"
119+
gh pr create \
120+
--title "chocolatey: Bump Headlamp version to $LATEST_HEADLAMP_TAG" \
121+
--base main \
122+
--assignee $user \
123+
--body "This PR updates the chocolatey package to the latest version of Headlamp" \
124+
env:
125+
GITHUB_TOKEN: ${{ secrets.KINVOLK_REPOS_TOKEN }}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
4a926c3f9175fca2f71bd777db33b0a9b272cd88e980f6d9ca3422ef99a0035e Headlamp-0.27.0-linux-arm64.AppImage
2+
cbaecfba70966938d6d9c6883b267e8c7e5f33c8b823a2d225d78a39f51921f6 Headlamp-0.27.0-linux-arm64.tar.gz
3+
2d369e7f9bb70676b7e48e2d8aafe667fc9748f7a4189074e8d7ad5e7ed01251 Headlamp-0.27.0-linux-armv7l.AppImage
4+
81e941a6b9f74b9f5abde787ff4a3d6022e5a6a003ce5a00a41ea7e0b85290f3 Headlamp-0.27.0-linux-armv7l.tar.gz
5+
0e12d342cd1cc491173d1cc0776049ad0cacf1f3972f87c7704d5a15031fba21 Headlamp-0.27.0-linux-x64.AppImage
6+
11955d1b81d3ce45ae13d03541904ab07222b0ebf84d077582102b454b9d2255 Headlamp-0.27.0-linux-x64.tar.gz
7+
d4ed9d1fe4313053ac5be577e12fdddbdc8495bef415147b518e81cdd3644249 Headlamp-0.27.0-mac-arm64.dmg
8+
a5e8b2821890012e2c5ef0695863a5d83bbbc66d64bc6a057a036fac6f2ad9c0 Headlamp-0.27.0-mac-x64.dmg
9+
b94dec3f29b0024a694e140ec0a343e8143d147f352fde095eda4908e141035d Headlamp-0.27.0-win-x64.exe
10+
6582c5500e3e76092c1d729596ebd13431c6089f71df604e28c83525552083b3 headlamp_0.27.0-1_amd64.deb

0 commit comments

Comments
 (0)