Skip to content

Fix release pipeline when there are no tags #2

Fix release pipeline when there are no tags

Fix release pipeline when there are no tags #2

Workflow file for this run

name: Create Release on PR merge
on:
pull_request:
types: [closed]
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Git
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Get the latest tag and increment version
id: version
run: |
# Get the latest tag and strip the 'v' from the version
latest_tag=$(git describe --tags --abbrev=0 2>/dev/null)
# If no tag exists, start from v1.0
if [[ -z "$latest_tag" ]]; then
latest_tag="v1.0"
# Create the initial tag (v1.0)
git tag $latest_tag
git push origin $latest_tag
fi
# Increment the version (e.g., v1.1 -> v1.2)
version_number=$(echo "$latest_tag" | sed 's/^v//')
version_array=(${version_number//./ })
major=${version_array[0]}
minor=${version_array[1]}
# Increment minor version by 1
minor=$((minor + 1))
# Ensure the version is in the form v1.x
new_version="v$major.$minor"
echo "New version: $new_version"
echo "::set-output name=version::$new_version"
- name: Create release files
run: |
version="${{ steps.version.outputs.version }}"
# Make sure the config folder is in the tar and zip files
mkdir -p release
cp -r config/nvim release/
# Create tar.gz file
tar -czf "release/$version.tar.gz" -C release .
# Create zip file
zip -r "release/$version.zip" release
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: release/*.tar.gz,release/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clean up
run: |
rm -rf release