Skip to content

Commit

Permalink
Add MSI building to workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ZetaTwo committed Dec 9, 2024
1 parent 5201f3e commit 8996c3c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
31 changes: 25 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
versionFlags: ${{ steps.flags.outputs.versionFlags }}
versionNumber: ${{ steps.flags.outputs.versionNumber }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
Expand All @@ -26,6 +27,7 @@ jobs:
"-X github.com/pomerium/cli/version.ProjectURL=https://www.pomerium.io"
)
echo "versionFlags=${ldflags[*]}" >> $GITHUB_OUTPUT
echo "versionNumber=$(echo ${{ github.event.release.tag_name }} | grep -o -P "\d+(?:\.\d+)*" || echo "1.0.0.0")" >> $GITHUB_OUTPUT
build-macos:
runs-on: macos-latest
Expand Down Expand Up @@ -70,7 +72,7 @@ jobs:
needs: metadata
strategy:
matrix:
arch: [amd64, arm64]
arch: [{go: amd64, wix: x64}, {go: arm64, wix: arm64}]
outputs:
checksums: ${{ steps.build.outputs.checksums }}
steps:
Expand All @@ -82,31 +84,48 @@ jobs:
with:
go-version: 1.23.x

- name: Set up .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Build
id: build
shell: bash
run: |
mkdir -p bin/${{ matrix.arch }}
GOARCH=${{ matrix.arch }} CGO_ENABLED=1 go build -o bin/${{ matrix.arch }} \
mkdir -p bin/${{ matrix.arch.go }}
GOARCH=${{ matrix.arch.go }} CGO_ENABLED=1 go build -o bin/${{ matrix.arch.go }} \
-ldflags="-s -w ${{ needs.metadata.outputs.versionFlags }}" \
./cmd/pomerium-cli
- name: Archive
id: archive
shell: bash
run: |
zipfile="pomerium-cli-windows-${{ matrix.arch }}.zip"
powershell "Compress-Archive -Path bin\\${{ matrix.arch }}\\\* -DestinationPath $zipfile"
zipfile="pomerium-cli-windows-${{ matrix.arch.go }}.zip"
powershell "Compress-Archive -Path bin\\${{ matrix.arch.go }}\\\* -DestinationPath $zipfile"
hash=$(powershell "(Get-FileHash $zipfile -Algorithm SHA256).Hash.ToLower()")
echo 'checksums<<EOF' >> $GITHUB_OUTPUT
echo "$hash $zipfile" >> $GITHUB_OUTPUT
echo EOF >> $GITHUB_OUTPUT
- name: Build MSI
id: msi
shell: bash
run: |
dotnet tool install --global wix
msifile="pomerium-cli-windows-${{ matrix.arch.go }}.msi"
wix build -arch ${{ matrix.arch.wix }} -b bin\\${{ matrix.arch.go }} -d "version=${{ needs.metadata.outputs.versionNumber }}" -o "$msifile" msi/PomeriumCli.wxs
hash=$(powershell "(Get-FileHash $msifile -Algorithm SHA256).Hash.ToLower()")
echo 'checksums<<EOF' >> $GITHUB_OUTPUT
echo "$hash $zipfile" >> $GITHUB_OUTPUT
echo EOF >> $GITHUB_OUTPUT
- name: Upload to release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload "${{ github.event.release.tag_name }}" pomerium-cli-windows-*.zip
run: gh release upload "${{ github.event.release.tag_name }}" pomerium-cli-windows-*.zip pomerium-cli-windows-*.msi

goreleaser:
permissions:
Expand Down
21 changes: 21 additions & 0 deletions msi/PomeriumCli.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package UpgradeCode="0A602749-404A-4192-84F3-9A7BA9F93EA1" Language="1033"
Manufacturer="Pomerium" Name="Pomerium CLI" Version="$(var.version)">
<MajorUpgrade AllowSameVersionUpgrades="yes"
DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />

<MediaTemplate EmbedCab="yes" />

<Feature Id="PomeriumCliFeature">
<ComponentRef Id="CliExecutable" />
</Feature>

<StandardDirectory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="Pomerium\Pomerium CLI">
<Component Id="CliExecutable">
<File Id="PomeriumCliExe" KeyPath="yes" Name="pomerium-cli.exe" Source="pomerium-cli.exe"></File>
</Component>
</Directory>
</StandardDirectory>
</Package>
</Wix>

0 comments on commit 8996c3c

Please sign in to comment.