Skip to content

Commit 9965a79

Browse files
authored
Merge pull request #4 from redjax/dev
Add github action to create releases on merges to main
2 parents f191648 + c330888 commit 9965a79

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

.github/workflows/release.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Create Release on PR merge
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- main
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Git
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: 3.x
20+
21+
- name: Get the latest tag and increment version
22+
id: version
23+
run: |
24+
# Get the latest tag and strip the 'v' from the version
25+
latest_tag=$(git describe --tags --abbrev=0)
26+
# If no tag exists, start from v1.0
27+
if [[ -z "$latest_tag" ]]; then
28+
latest_tag="v1.0"
29+
fi
30+
# Increment the version (e.g., v1.1 -> v1.2)
31+
version_number=$(echo "$latest_tag" | sed 's/^v//')
32+
version_array=(${version_number//./ })
33+
major=${version_array[0]}
34+
minor=${version_array[1]}
35+
36+
# Increment minor version by 1
37+
minor=$((minor + 1))
38+
39+
# Ensure the version is in the form v1.x
40+
new_version="v$major.$minor"
41+
42+
echo "New version: $new_version"
43+
echo "::set-output name=version::$new_version"
44+
45+
- name: Create release files
46+
run: |
47+
version="${{ steps.version.outputs.version }}"
48+
# Make sure the config folder is in the tar and zip files
49+
mkdir -p release
50+
cp -r config/nvim release/
51+
52+
# Create tar.gz file
53+
tar -czf "release/$version.tar.gz" -C release .
54+
55+
# Create zip file
56+
zip -r "release/$version.zip" release
57+
58+
- name: Create GitHub Release
59+
uses: softprops/action-gh-release@v2
60+
with:
61+
files: release/*.tar.gz,release/*.zip
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
65+
- name: Clean up
66+
run: |
67+
rm -rf release

0 commit comments

Comments
 (0)