Skip to content

Commit 8da4628

Browse files
committed
add workflow to update lsp-bridge daily and release automatically
1 parent 7a3c57c commit 8da4628

File tree

2 files changed

+73
-2
lines changed

2 files changed

+73
-2
lines changed

.github/workflows/schedule.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: "Daily Update and Release"
2+
on:
3+
schedule:
4+
- cron: '0 0 * * *' # Run daily at midnight UTC
5+
workflow_dispatch: # Allow manual triggering
6+
7+
jobs:
8+
update-and-test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
13+
- name: Set up Nix
14+
uses: cachix/install-nix-action@v22
15+
16+
- name: Install just
17+
run: |
18+
nix-env -iA nixpkgs.just
19+
nix-env -iA nixpkgs.jq
20+
21+
- name: Update lsp-bridge.nix and run tests
22+
id: update_and_test
23+
run: |
24+
if ! just test; then
25+
echo "First test run failed, retrying..."
26+
if just test; then
27+
echo "Second test run succeeded"
28+
echo "test_passed=true" >> $GITHUB_OUTPUT
29+
30+
# update the version for release tag
31+
just update_version
32+
else
33+
echo "Second test after re-generation run failed"
34+
exit 1
35+
fi
36+
fi
37+
38+
- name: Commit and push changes if any
39+
if: steps.update_and_test.outputs.test_passed == 'true'
40+
run: |
41+
git config --global user.name 'GitHub Actions Bot'
42+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
43+
git add _generator/ src/ test/
44+
if git diff --staged --quiet; then
45+
echo "No changes to commit"
46+
else
47+
git commit -m "Update lsp-bridge to latest version"
48+
git push
49+
fi

justfile

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,37 @@ test: generate
2222

2323
if [ -n "$got_value" ]; then
2424
echo "The 'got:' value is: $got_value"
25-
sed -i "s/sha256 = .*/sha256 = $got_value/" _generator/src_template/{{cookiecutter.langserver}}/lsp-bridge.nix
26-
25+
sed -i "s|sha256 = .*|sha256 = $got_value|" _generator/src_template/{{{{cookiecutter.langserver}}/lsp-bridge.nix
26+
2727
echo "Updated lsp-bridge.nix with the new sha256 value."
2828
echo "Generate and test again."
2929
exit 1
3030
else
3131
echo "Test passed"
3232
fi
3333

34+
# update the version for release tag
35+
update_version:
36+
#!/bin/bash
37+
file="_generator/src_template/{{{{cookiecutter.langserver}}/devcontainer-feature.json"
38+
39+
# Read the current version
40+
current_version=$(jq -r '.version' "$file")
41+
42+
# Split the version into parts
43+
IFS='.' read -ra version_parts <<< "$current_version"
44+
45+
# Increment the last part
46+
((version_parts[2]++))
47+
48+
# Join the parts back together
49+
new_version="${version_parts[0]}.${version_parts[1]}.${version_parts[2]}"
50+
51+
# Update the file with the new version
52+
jq --arg version "$new_version" '.version = $version' "$file" > temp.json && mv temp.json "$file"
53+
54+
echo "Version updated from $current_version to $new_version"
55+
3456
# open a devcontainer in VSCode
3557
devcontainer:
3658
p=$(printf "%s" "$PWD" | hexdump -v -e '/1 "%02x"') && code --folder-uri "vscode-remote://dev-container+${p}/workspaces/$(basename $PWD)"

0 commit comments

Comments
 (0)