-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1784 from headlamp-k8s/winget-automation
winget: Add automated winget draft pr
- Loading branch information
Showing
1 changed file
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
name: PR for updating winget | ||
|
||
# This action will run after a tag starting with "v" is published | ||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
winget-update: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout winget-automation | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: winget-automation | ||
token: ${{ secrets.KINVOLK_REPOS_TOKEN }} | ||
# we need the full history for the git tag command, so fetch all the branches | ||
fetch-depth: 0 | ||
|
||
- name: Configure Git | ||
run: | | ||
user=${{github.actor}} | ||
if [ -z $user ]; then | ||
user=vyncent-t | ||
fi | ||
git config --global user.name "$user" | ||
git config --global user.email "$user@users.noreply.github.com" | ||
# Set up Node.js environment, pay attention to the version | ||
# Some features might not be available in older versions | ||
- name: Create node.js environment | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "21" | ||
|
||
# Install the dependencies for the winget script | ||
- name: Install winget dependencies | ||
run: | | ||
cd $GITHUB_WORKSPACE/app | ||
npm install | ||
# We set the latest tag as an environment variable before we use it in the next steps | ||
# note that we have to echo the variable to the environment file to make it available in the next steps | ||
- name: Set latest tag | ||
run: | | ||
echo "Setting latest tag" | ||
latestTag=$(git tag --list --sort=version:refname 'v*' | tail -1) | ||
# Remove the 'v' from the tag | ||
latestTag=${latestTag#v} | ||
echo "LATEST_HEADLAMP_TAG=$latestTag" >> $GITHUB_ENV | ||
echo $latestTag | ||
# checkout the winget-pkgs repository | ||
- name: Checkout winget-pkgs | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: headlamp-k8s/winget-pkgs | ||
path: winget-pkgs | ||
token: ${{ secrets.KINVOLK_REPOS_TOKEN }} | ||
# we need the full history for the git tag command, so fetch all the branches | ||
fetch-depth: 0 | ||
|
||
# Run the winget script | ||
- name: Create winget package | ||
run: | | ||
echo "Running winget script" | ||
echo "Repository: ${{ github.repository }}" | ||
echo "Workspace: ${GITHUB_WORKSPACE}" | ||
echo $GITHUB_WORKSPACE | ||
pwd | ||
echo "creating winget pkgs for ${LATEST_HEADLAMP_TAG}" | ||
cd $GITHUB_WORKSPACE/app/windows/winget | ||
node winget-create.js $LATEST_HEADLAMP_TAG $GITHUB_WORKSPACE/winget-pkgs/manifests/h/Headlamp/Headlamp | ||
echo "Script finished" | ||
- name: Create PR branch | ||
run: | | ||
user=${{github.actor}} | ||
if [ -z $user ]; then | ||
user=vyncent-t | ||
fi | ||
echo "Creating PR branch" | ||
echo "Repository: ${{ github.repository }}" | ||
echo "Workspace: ${GITHUB_WORKSPACE}" | ||
pwd | ||
echo "moving to winget-pkgs directory" | ||
cd $GITHUB_WORKSPACE/winget-pkgs | ||
pwd | ||
ls | ||
echo "moving to Headlamp directory" | ||
cd $GITHUB_WORKSPACE/winget-pkgs/manifests/h/Headlamp/Headlamp | ||
pwd | ||
ls | ||
git checkout -b "winget-update-$LATEST_HEADLAMP_TAG" | ||
git add . | ||
git commit -s -m "Update winget package $LATEST_HEADLAMP_TAG" | ||
git push origin "winget-update-$LATEST_HEADLAMP_TAG" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.KINVOLK_REPOS_TOKEN }} | ||
|
||
- name: Create Pull Request | ||
run: | | ||
echo "Create pull request" | ||
echo "continue with the following link" | ||
echo "https://github.com/headlamp-k8s/winget-pkgs/pull/new/winget-update-$LATEST_HEADLAMP_TAG" |