From 05cacecf67e672542c8252b12fabf55c80b56b02 Mon Sep 17 00:00:00 2001 From: Andreas Salhus Bakseter <141913422+baksetercx@users.noreply.github.com> Date: Tue, 19 Nov 2024 14:15:30 +0100 Subject: [PATCH 1/3] Make MSI installed add exe to PATH --- build/package/3lv-amd64.wxs | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/build/package/3lv-amd64.wxs b/build/package/3lv-amd64.wxs index d7464de..aec1abf 100644 --- a/build/package/3lv-amd64.wxs +++ b/build/package/3lv-amd64.wxs @@ -24,22 +24,33 @@ - - - + + + - - - + + + - + + - - + - + + + + + From 28b454456465f15c2195350887fed590b4ef9a8f Mon Sep 17 00:00:00 2001 From: Andreas Salhus Bakseter <141913422+baksetercx@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:50:47 +0100 Subject: [PATCH 2/3] Use WiX on Windows, wixl (Linux) doesn't support updating PATH --- .github/workflows/build-release.yml | 37 +++++++------- .gitignore | 3 ++ Makefile | 10 ++-- build/package/3lv-amd64.wxs | 78 +++++++++++------------------ 4 files changed, 55 insertions(+), 73 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 06c47a5..de5d4f5 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -9,10 +9,7 @@ on: jobs: build: name: Build - runs-on: elvia-runner - outputs: - version-tag: ${{ steps.get-version.outputs.version_tag }} - major-version-tag: ${{ steps.get-version.outputs.major_version_tag }} + runs-on: ${{ matrix.os == 'windows' && 'windows-latest' || 'elvia-runner' }} strategy: matrix: os: [linux, macos, windows] @@ -30,27 +27,24 @@ jobs: with: go-version-file: 'go.mod' - - name: Resolve version - id: get-version - run: | - version=$(cat VERSION) - echo "VERSION_TAG=v$version" >> "$GITHUB_OUTPUT" - echo "MAJOR_VERSION_TAG=v$(echo $version | cut -d. -f1)" >> "$GITHUB_OUTPUT" + - name: Add MSBuild to PATH + if: ${{ matrix.os == 'windows' }} + uses: microsoft/setup-msbuild@v2 - # TODO: remove when wixl is pre-installed on elvia-runner runners - - name: Install dependencies for Windows + - name: Install WiX if: ${{ matrix.os == 'windows' }} - run: sudo apt-get install -y --no-install-recommends wixl + run: dotnet tool install --global wix - - name: Package CLI - run: make package-${{ matrix.os }}-${{ matrix.arch }} + - name: Package binaries + shell: bash + run: make 'package-${{ matrix.os }}-${{ matrix.arch }}' - name: Upload artifacts (on push) if: ${{ github.event_name == 'push' }} uses: actions/upload-artifact@v4 with: name: '3lv-${{ matrix.os }}-${{ matrix.arch }}' - path: '/tmp/3lv/dist' + path: 'dist/package/*' pre-release: name: Pre-release @@ -58,16 +52,21 @@ jobs: runs-on: elvia-runner if: ${{ github.event_name == 'push' }} outputs: + version-tag: ${{ steps.get-version.outputs.version_tag }} new-version: ${{ steps.create-pre-release.outputs.new_version }} - env: - VERSION_TAG: ${{ needs.build.outputs.version-tag }} - MAJOR_VERSION_TAG: ${{ needs.build.outputs.major-version-tag }} permissions: contents: write steps: - name: Checkout repository uses: actions/checkout@v4 + - name: Resolve version + id: get-version + run: | + version=$(cat VERSION) + echo "VERSION_TAG=v$version" | tee -a "$GITHUB_ENV" "$GITHUB_OUTPUT" + echo "MAJOR_VERSION_TAG=v$(echo $version | cut -d. -f1)" >> "$GITHUB_ENV" + - name: Create pre-release if new version id: create-pre-release run: | diff --git a/.gitignore b/.gitignore index 6f72f89..16fd994 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ go.work.sum # env file .env + +# Build & packaging output +dist/ diff --git a/Makefile b/Makefile index 3051020..5f74bdb 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ main_package_path = . binary_name = 3lv -build_dir = /tmp/3lv/bin -package_dir = /tmp/3lv/dist +build_dir = ./dist/bin +package_dir = ./dist/package go_os = $(shell go env GOOS) go_arch = $(shell go env GOARCH) @@ -82,14 +82,12 @@ package-macos-arm64: go_arch=arm64 package-macos-arm64: package ## package-windows-amd64: Build and then package the binary for Windows (amd64). +## Only works on Windows, requires WiX Toolset to be installed. .PHONY: package-windows-amd64 package-windows-amd64: build-windows-amd64 package-windows-amd64: - mkdir -p ${package_dir} - cp LICENSE README.md build/package/3lv-${go_arch}.wxs ${build_dir}/3lv-${go_arch}.exe ${package_dir} - cd ${package_dir} && wixl -v -o 3lv-${go_arch}.msi 3lv-${go_arch}.wxs + wix build build/package/3lv-${go_arch}.wxs -o ${package_dir}/3lv-${go_arch}.msi cd ${package_dir} && md5sum 3lv-${go_arch}.msi > 3lv-${go_arch}.msi.md5 - cd ${package_dir} && rm -f LICENSE README.md 3lv-${go_arch}.wxs 3lv-${go_arch}.exe ## install: Build and then install the binary to /usr/local/bin. Requires root. Only works on Linux and macOS (tries to guess the OS and architecture). .PHONY: install diff --git a/build/package/3lv-amd64.wxs b/build/package/3lv-amd64.wxs index aec1abf..667b63c 100644 --- a/build/package/3lv-amd64.wxs +++ b/build/package/3lv-amd64.wxs @@ -1,56 +1,38 @@ - - - + - + - - + + - - - - + + + - - - + + + + + + - + + + + + + - - - - - - - - - - - + + From b60c53c1e7bae191d760615db7c716f318adedbb Mon Sep 17 00:00:00 2001 From: Andreas Salhus Bakseter <141913422+baksetercx@users.noreply.github.com> Date: Tue, 19 Nov 2024 14:16:25 +0100 Subject: [PATCH 3/3] 0.18.0-alpha3 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index ab06b5f..be46dea 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.18.0-alpha2 +0.18.0-alpha3