Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/wix native #115

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -30,44 +27,46 @@ 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
needs: [build]
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: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ go.work.sum

# env file
.env

# Build & packaging output
dist/
10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.18.0-alpha2
0.18.0-alpha3
69 changes: 31 additions & 38 deletions build/package/3lv-amd64.wxs
Original file line number Diff line number Diff line change
@@ -1,45 +1,38 @@
<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<Product
Name='Elvia CLI'
Id='432286C8-BC7F-4919-8432-67107E4E45AA'
UpgradeCode='0CD31A27-AA46-4E75-BDBB-E008F751FC76'
Language='1033'
Codepage='1252'
Version='1.7.3'
Manufacturer='Elvia AS'
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package
Name="Elvia CLI"
UpgradeCode="0CD31A27-AA46-4E75-BDBB-E008F751FC76"
Language="1033"
Codepage="1252"
Version="1.7.3"
Manufacturer="Elvia AS"
InstallerVersion="100"
ProductCode="432286C8-BC7F-4919-8432-67107E4E45AA"
>
<Package
Id='*'
Keywords='Installer'
Description="Elvia CLI installer"
Manufacturer='Elvia AS'
InstallerVersion='100'
Languages='1033'
Compressed='yes'
SummaryCodepage='1252'
/>
<SummaryInformation Keywords="Installer" Description="Elvia CLI installer" Manufacturer="Elvia AS" />

<Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" />
<Property Id='DiskPrompt' Value="Elvia CLI Installation [1]" />
<Media Id="1" Cabinet="Sample.cab" EmbedCab="yes" DiskPrompt="CD-ROM #1" />
<Property Id="DiskPrompt" Value="Elvia CLI Installation [1]" />

<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<Directory Id='Elvia' Name='Elvia'>
<Directory Id='INSTALLDIR' Name='Elvia CLI'>

<Component Id='MainExecutable' Guid='B9716B0E-A39B-4B2E-94CE-250C40018EBB'>
<File Id='3lvEXE' Name='3lv.exe' DiskId='1' Source='3lv-amd64.exe' KeyPath='yes'/>
</Component>

</Directory>
</Directory>
</Directory>
</Directory>
<Feature Id="Complete" Level="1">
<ComponentRef Id="MainExecutable" />
</Feature>

<Feature Id='Complete' Level='1'>
<ComponentRef Id='MainExecutable' />
<Feature Id="Environment" Level="1">
<Component Id="SetEnvironment" Guid="43B01B46-A693-4BCD-9EC7-068BC533E617" Directory="TARGETDIR">
<CreateFolder />
<Environment Id="PATH" Name="PATH" Value="[INSTALLDIR]" Permanent="no" Part="last" Action="set" System="no" />
</Component>
</Feature>

</Product>
<StandardDirectory Id="ProgramFilesFolder">
<Directory Id="Elvia" Name="Elvia">
<Directory Id="INSTALLDIR" Name="Elvia CLI">
<Component Id="MainExecutable" Guid="B9716B0E-A39B-4B2E-94CE-250C40018EBB">
<File Id="ElviaCliEXE" Name="3lv-amd64.exe" DiskId="1" Source="$(sys.CURRENTDIR)\dist\bin\3lv-amd64.exe" KeyPath="yes" />
</Component>
</Directory>
</Directory>
</StandardDirectory>
</Package>
</Wix>