Repository navigation
75 lines (66 loc) · 3.68 KB
/
Copy pathrelease-vim.yml
File metadata and controls
75 lines (66 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: release-vim
# extensions/vim is a plain-Vimscript plugin with nothing to build or publish anywhere — users install it directly from this repo via a plugin manager's `rtp` option (see its README). This workflow only tags a commit and creates a GitHub Release for it, so a user who wants to pin to a specific version can, rather than tracking main.
on:
workflow_dispatch:
inputs:
version:
description: "Version bump for kiritan-vim: patch/minor/major/prerelease, or an explicit version (e.g. 0.2.0)"
required: true
default: patch
permissions:
contents: write # create the tag and the GitHub Release
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# `fetch-tags: true` alone isn't enough with the default shallow (depth-1) fetch: git only auto-follows tags that point at commits already in the fetched history, and an existing release tag almost always points further back than the latest commit. Fetch full history instead — the same fix _release-package.yml and release-vscode.yml already use — so `git tag --list 'kiritan-vim@*'` below actually sees the last release instead of silently re-deriving every version from 0.0.0 (this is what broke the 0.1.0 -> 0.1.0 "minor" bump and the tag-already-exists push failure).
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
# So extensions/vim's tests actually run (not just skip) before tagging. apt's neovim package is too old for vim.system/vim.fs.root (added in 0.10), so install a real release directly instead.
- run: sudo apt-get update && sudo apt-get install -y vim
- name: Install Neovim
run: |
curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux-x86_64.tar.gz
sudo tar -C /opt -xzf nvim-linux-x86_64.tar.gz
sudo ln -sf /opt/nvim-linux-x86_64/bin/nvim /usr/local/bin/nvim
rm nvim-linux-x86_64.tar.gz
- run: npm ci
- run: npm run ci
- run: npm run typecheck
- run: npm run test
- name: Determine version
id: version
run: |
LATEST_TAG="$(git tag --list 'kiritan-vim@*' --sort=-v:refname | head -1)"
CURRENT="${LATEST_TAG#kiritan-vim@}"
CURRENT="${CURRENT:-0.0.0}"
# extensions/vim has no package.json to bump the same way release.yml's _release-package.yml does via `npm version` — reuse that exact same semver logic (accepting both a patch/minor/major/prerelease keyword and an explicit version) anyway, via a throwaway package.json.
SCRATCH="$(mktemp -d)"
echo "{\"name\":\"kiritan-vim-version-scratch\",\"version\":\"$CURRENT\"}" > "$SCRATCH/package.json"
NEW="$(npm --prefix "$SCRATCH" version "${{ inputs.version }}" --no-git-tag-version --allow-same-version | sed 's/^v//')"
rm -rf "$SCRATCH"
echo "new=$NEW" >> "$GITHUB_OUTPUT"
echo "tag=kiritan-vim@$NEW" >> "$GITHUB_OUTPUT"
- name: Tag and push
run: |
TAG="${{ steps.version.outputs.tag }}"
if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then
echo "::error::Tag $TAG already exists"
exit 1
fi
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "$TAG"
git push origin "$TAG"
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${{ steps.version.outputs.tag }}" \
--title "${{ steps.version.outputs.tag }}" \
--generate-notes