Skip to content

Commit 693e6c0

Browse files
committed
ci: add automatic release on version changed in Cargo.toml
1 parent d4e3bc4 commit 693e6c0

File tree

4 files changed

+197
-0
lines changed

4 files changed

+197
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{{ range .Versions }}
2+
{{ range .CommitGroups -}}
3+
### {{ .Title }}
4+
5+
{{ range .Commits -}}
6+
* {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
7+
{{ end }}
8+
{{ end -}}
9+
10+
{{- if .RevertCommits -}}
11+
### Reverts
12+
13+
{{ range .RevertCommits -}}
14+
* {{ .Revert.Header }}
15+
{{ end }}
16+
{{ end -}}
17+
18+
{{- if .NoteGroups -}}
19+
{{ range .NoteGroups -}}
20+
### {{ .Title }}
21+
22+
{{ range .Notes }}
23+
{{ .Body }}
24+
{{ end }}
25+
{{ end -}}
26+
{{ end -}}
27+
{{ end -}}

.github/git-chglog/config.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
style: github
2+
template: CHANGELOG.tpl.md
3+
info:
4+
title: CHANGELOG
5+
repository_url: https://github.com/sysdiglabs/sysdig-lsp
6+
options:
7+
commits:
8+
# filters:
9+
# Type:
10+
# - feat
11+
# - fix
12+
# - perf
13+
# - refactor
14+
commit_groups:
15+
title_maps:
16+
feat: Features
17+
fix: Bug Fixes
18+
perf: Performance Improvements
19+
refactor: Code Refactoring
20+
ci: Continuous Integration
21+
docs: Documentation
22+
chore: Small Modifications
23+
build: Compilation & Dependencies
24+
header:
25+
pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$"
26+
pattern_maps:
27+
- Type
28+
- Scope
29+
- Subject
30+
notes:
31+
keywords:
32+
- BREAKING CHANGE

.github/workflows/release.yml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
name: Release new version
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- Cargo.toml
9+
jobs:
10+
get-newer-version:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
new-version: ${{ steps.check.outputs.new_version }}
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-tags: true
19+
20+
- name: Extract version from Cargo.toml
21+
id: extract
22+
run: |
23+
VERSION=$(grep -m1 '^version\s*=' Cargo.toml | sed -E 's/version\s*=\s*"([^"]+)".*/\1/')
24+
echo "Extracted version: $VERSION"
25+
echo "version=$VERSION" >> $GITHUB_OUTPUT
26+
27+
- name: Get latest tag
28+
id: latest
29+
run: |
30+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "none")
31+
echo "Latest tag: $LATEST_TAG"
32+
echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT
33+
34+
- name: Check if version is new
35+
id: check
36+
run: |
37+
VERSION="${{ steps.extract.outputs.version }}"
38+
LATEST="${{ steps.latest.outputs.latest_tag }}"
39+
if [ "$VERSION" = "$LATEST" ]; then
40+
echo "No new version detected."
41+
echo "new_version=" >> $GITHUB_OUTPUT
42+
else
43+
echo "New version detected: $VERSION"
44+
echo "new_version=$VERSION" >> $GITHUB_OUTPUT
45+
fi
46+
47+
build:
48+
name: Build ${{ matrix.os }}-${{ matrix.arch }}
49+
needs: get-newer-version
50+
if: needs.get-newer-version.outputs.new-version != ''
51+
runs-on: ${{ matrix.runner }}
52+
strategy:
53+
matrix:
54+
include:
55+
- runner: ubuntu-latest
56+
os: linux
57+
arch: arm64
58+
- runner: ubuntu-latest
59+
os: linux
60+
arch: amd64
61+
- runner: macos-latest
62+
os: darwin
63+
arch: arm64
64+
- runner: macos-latest
65+
os: darwin
66+
arch: amd64
67+
# - runner: ubuntu-latest # Not supported by the CLI Scanner yet
68+
# os: windows
69+
# arch: amd64
70+
steps:
71+
- name: Checkout code
72+
uses: actions/checkout@v4
73+
74+
- name: Install Nix
75+
uses: DeterminateSystems/nix-installer-action@main
76+
77+
- name: Configure Nix cache
78+
uses: DeterminateSystems/flakehub-cache-action@main
79+
80+
- name: Build LSP for ${{ matrix.os }}-${{ matrix.arch }}
81+
run: nix build -L .#sysdig-lsp-${{ matrix.os }}-${{ matrix.arch }}
82+
83+
- name: Copy binary built
84+
run: cp -a ./result/bin/sysdig-lsp /tmp/sysdig-lsp-${{ matrix.os }}-${{ matrix.arch }}
85+
86+
- name: Upload binary
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: sysdig-lsp-${{ matrix.os }}-${{ matrix.arch }}
90+
path: /tmp/sysdig-lsp-${{ matrix.os }}-${{ matrix.arch }}
91+
if-no-files-found: error
92+
retention-days: 1
93+
94+
release:
95+
name: Create release at Github
96+
needs: [ build, get-newer-version ]
97+
if: needs.get-newer-version.outputs.new-version != ''
98+
runs-on: ubuntu-latest
99+
permissions:
100+
contents: write # Required for release creation
101+
steps:
102+
- uses: actions/checkout@v4
103+
with:
104+
fetch-depth: 0
105+
fetch-tags: true
106+
107+
- name: Install Nix
108+
uses: DeterminateSystems/nix-installer-action@main
109+
110+
- name: Configure Nix cache
111+
uses: DeterminateSystems/flakehub-cache-action@main
112+
113+
- name: Install git-chglog
114+
run: nix profile install nixpkgs#git-chglog
115+
116+
- name: Tag with version ${{ needs.get-newer-version.outputs.new-version }}
117+
run: git tag ${{ needs.get-newer-version.outputs.new-version }}
118+
119+
- name: Generate changelog
120+
run: git-chglog -c .github/git-chglog/config.yml -o RELEASE_CHANGELOG.md $(git describe --tags $(git rev-list --tags --max-count=1))
121+
122+
- name: Download artifacts
123+
uses: actions/download-artifact@v4
124+
with:
125+
pattern: sysdig-lsp-*
126+
path: /tmp/
127+
merge-multiple: true
128+
129+
- name: Create release
130+
uses: softprops/action-gh-release@v2
131+
with:
132+
name: Sysdig LSP ${{ needs.get-newer-version.outputs.new-version }}
133+
tag_name: ${{ needs.get-newer-version.outputs.new-version }}
134+
prerelease: false
135+
body_path: RELEASE_CHANGELOG.md
136+
files: |
137+
/tmp/sysdig-lsp-*

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "sysdig-lsp"
33
version = "0.1.0"
44
edition = "2024"
55

6+
67
[dependencies]
78
async-trait = "0.1.85"
89
chrono = { version = "0.4.40", features = ["serde"] }

0 commit comments

Comments
 (0)