feat: Create Neogen semver

This commit is contained in:
danymat
2022-02-08 20:08:12 +01:00
parent 767169cc43
commit 77b5c1a535
5 changed files with 66 additions and 0 deletions

28
.github/workflows/semver.yml vendored Normal file
View File

@@ -0,0 +1,28 @@
name: Generates Neogen tag
on:
push:
branches:
- main
jobs:
gen_tag:
strategy:
fail-fast: false
matrix:
version:
- nightly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Neovim
uses: rhysd/action-setup-vim@v1
id: neovim
with:
neovim: true
version: ${{ matrix.version }}
- uses: actions/checkout@v1 # related: actions/checkout#290
- name: Run tag_gen
run: make tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -1,2 +1,5 @@
documentation:
nvim --headless --noplugin -u ./scripts/minimal_init.vim -c "lua MiniDoc.generate()" -c "qa!"
tag:
./scripts/generate_tag.sh

View File

@@ -21,6 +21,7 @@
---@toc_entry Neogen's purpose
-- Requires ===================================================================
local neogen = {}
neogen.version = "1.0.0"
local conf
local config = require("neogen.config")

33
scripts/generate_tag.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
# Copied from https://github.com/nvim-neorg/neorg/blob/main/scripts/generate_tag.sh
current_version=$(nvim --headless --noplugin -u ./scripts/minimal_init.vim -c 'luafile ./scripts/get_version.lua' -c 'qa' 2>&1 | tr -d \")
# get current commit hash for tag
commit=$(git rev-parse HEAD)
# Creates a new tag for current version
push_tag() {
curl -s -X POST https://api.github.com/repos/danymat/neogen/git/refs \
-H "Authorization: token $GITHUB_TOKEN" \
-d @- << EOF
{
"ref": "refs/tags/$current_version",
"sha": "$commit"
}
EOF
echo "Generated new tag: $current_version"
}
echo "Current version: $current_version"
echo "Last commit: $commit"
echo "Existing tags: $(git tag -l)"
if [ $(git tag -l "$current_version") ]; then
echo "No new Neogen version (current: $current_version)"
exit 0
else
push_tag
fi

1
scripts/get_version.lua Normal file
View File

@@ -0,0 +1 @@
print(require('neogen').version)