From d7cbc9f454d8e7442b695b62169561f1aa3840d3 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Wed, 16 Oct 2024 21:33:40 +0200 Subject: [PATCH] fix(ci-cd): Improve CI:CD --- .github/workflows/release-nightly.yaml | 9 +++++++++ flake.nix | 5 +++-- server/root-handler/handler.go | 4 +++- vs-code-extension/package.json | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-nightly.yaml b/.github/workflows/release-nightly.yaml index f0e8e60..14fc41b 100644 --- a/.github/workflows/release-nightly.yaml +++ b/.github/workflows/release-nightly.yaml @@ -12,6 +12,15 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Check version in code matches flake version + shell: bash + run: | + if ! [ $(grep '// CI:CD-VERSION$' server/root-handler/handler.go | cut -d'"' -f 2) = $(nix eval --file flake.nix inputs.version | cut -d '"' -f 2) ]; + then + echo "Version mismatch" + exit 1 + fi + - uses: cachix/install-nix-action@v27 with: github_access_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/flake.nix b/flake.nix index be65ac1..a15c626 100644 --- a/flake.nix +++ b/flake.nix @@ -9,9 +9,10 @@ inputs.utils.follows = "utils"; }; utils.url = "github:numtide/flake-utils"; + version = "0.1.0"; }; - outputs = { self, nixpkgs, utils, gomod2nix }: + outputs = { self, nixpkgs, utils, gomod2nix, version }: utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { @@ -30,7 +31,7 @@ server = pkgs.buildGoModule { nativeBuildInputs = inputs; pname = "github.com/Myzel394/config-lsp"; - version = "v0.0.1"; + version = version; src = ./server; vendorHash = "sha256-s+sjOVvqU20+mbEFKg+RCD+dhScqSatk9eseX2IioPI"; checkPhase = '' diff --git a/server/root-handler/handler.go b/server/root-handler/handler.go index afc666d..6884739 100644 --- a/server/root-handler/handler.go +++ b/server/root-handler/handler.go @@ -9,7 +9,9 @@ import ( const lsName = "config-lsp" -var version string = "0.0.1" +// The comment below at the end of the line is required for the CI:CD to work. +// Do not remove it +var version = "0.1.0" // CI:CD-VERSION var lspHandler protocol.Handler diff --git a/vs-code-extension/package.json b/vs-code-extension/package.json index 9c38a0d..a7fc5c5 100644 --- a/vs-code-extension/package.json +++ b/vs-code-extension/package.json @@ -3,7 +3,7 @@ "description": "A language server example using language services to support embedded languages", "author": "Microsoft Corporation", "license": "MIT", - "version": "1.0.0", + "version": "0.1.0", "repository": { "type": "git", "url": "https://github.com/Microsoft/vscode-extension-samples"