Skip to content

Fix cgo environment variable for release (#613) #68

Fix cgo environment variable for release (#613)

Fix cgo environment variable for release (#613) #68

Workflow file for this run

name: Release binaries
permissions: {}
on:
push:
tags:
- "v*"
jobs:
compile-gui:
# Compile the GUI on Windows & Linux, and write the GUI binaries to actions/cache
name: Compile GUI
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
persist-credentials: false
- name: Fetch cached compiled GUI
id: restore-compiled-gui
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
# enableCrossOsArchive always needs to be set on cached items in Windows jobs
# see cache documentation: https://github.com/actions/cache#inputs
enableCrossOsArchive: true
path: gui/dist/cloudfuseGUI_${{ runner.os }}
key: ${{ runner.os }}-compiled-gui-${{ hashFiles('gui/*.ui', 'gui/*.py') }}
- name: Install Python
if: ${{ ! steps.restore-compiled-gui.outputs.cache-hit }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.12"
- name: Install pip dependencies
if: ${{ ! steps.restore-compiled-gui.outputs.cache-hit }}
run: pip3 install -r gui/requirements.txt
shell: bash
- name: Install libxcb-cursor0
if: ${{ ! steps.restore-compiled-gui.outputs.cache-hit && matrix.os == 'ubuntu-latest' }}
run: |-
sudo apt-get update
sudo apt-get install libxcb-cursor0 -y
- name: Compile GUI
if: ${{ ! steps.restore-compiled-gui.outputs.cache-hit }}
shell: bash
env:
OS: ${{ runner.os }}
run: |
cd gui
./create_gui.sh
mv dist/cloudfuseGUI dist/cloudfuseGUI_${OS}
- name: Cache compiled GUI
if: ${{ ! steps.restore-compiled-gui.outputs.cache-hit }}
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
enableCrossOsArchive: true
path: gui/dist/cloudfuseGUI_${{ runner.os }}
key: ${{ runner.os }}-compiled-gui-${{ hashFiles('gui/*.ui', 'gui/*.py') }}
create-installer:
# Run Inno Setup to create the Windows app installer, then write it to actions/cache
name: Create Windows Installer
needs: compile-gui
runs-on: windows-latest
env:
go: "1.24"
cgo: "0"
winfsp: winfsp-2.1.25156.msi
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
persist-credentials: false
- name: Install Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
with:
go-version: ${{ env.go }}
check-latest: true
cache: false
- name: Set CGO
shell: bash
run: |
echo 'CGO_ENABLED=0' >> $GITHUB_ENV
- name: Build
shell: bash
env:
SHA: ${{ github.sha }}
run: |
commitDate=$(TZ=UTC0 git log -1 --format=%cd --date=format-local:%Y-%m-%dT%H:%M:%SZ)
ldflags="-s -w -X github.com/Seagate/cloudfuse/common.GitCommit=${SHA} -X github.com/Seagate/cloudfuse/common.CommitDate=$commitDate"
go build -trimpath -ldflags ''"$ldflags"'' -o cloudfuse.exe
go build -trimpath -ldflags ''"$ldflags"'' -o cfusemon.exe ./tools/health-monitor/
go build -trimpath -ldflags ''"$ldflags"'' -o windows-startup.exe ./tools/windows-startup/
go build -trimpath -ldflags ''"$ldflags"'' -o windows-service.exe ./tools/windows-service/
touch -m -d $commitDate cloudfuse.exe
touch -m -d $commitDate cfusemon.exe
touch -m -d $commitDate windows-startup.
touch -m -d $commitDate windows-service.exe
# Get the WinFSP installer (from cache or download)
- name: Get cached WinFSP installer
id: restore-winfsp-installer
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
path: ${{ env.winfsp }}
key: ${{ env.winfsp }}
- name: Download WinFSP installer
if: ${{ ! steps.restore-winfsp-installer.outputs.cache-hit }}
shell: bash
env:
WINFSP: ${{ env.winfsp }}
run: |
curl -LOf https://github.com/winfsp/winfsp/releases/download/v2.1/${WINFSP}
- name: Cache WinFSP installer
if: ${{ ! steps.restore-winfsp-installer.outputs.cache-hit }}
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
path: ${{ env.winfsp }}
key: ${{ env.winfsp }}
- name: Fetch cached compiled GUI
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
enableCrossOsArchive: true
path: gui/dist/cloudfuseGUI_${{ runner.os }}
key: ${{ runner.os }}-compiled-gui-${{ hashFiles('gui/*.ui', 'gui/*.py') }}
fail-on-cache-miss: true
# don't continue if we fail get the compiled GUI for the Windows installer
continue-on-error: false
- name: Set Version
id: get_version
shell: bash
run: echo "VERSION=${REF_NAME#v}" >> $GITHUB_OUTPUT
env:
REF_NAME: ${{ github.ref_name }}
- name: Run Inno Setup
# Build the installer and save it to actions/cache
working-directory: ./build
shell: bash
# Inno Setup is pre-installed on GitHub's windows-latest image
# see documentation: https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md
run: |
"C:/Program Files (x86)/Inno Setup 6/iscc.exe" windows_installer_build.iss
- name: Rename installer
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
run: |
mv build/Output/cloudfuse.exe build/Output/cloudfuse_${VERSION}_windows_amd64.exe
- name: Run Inno Setup for No Gui
working-directory: ./build
shell: bash
# Inno Setup is pre-installed on GitHub's windows-latest image
# see documentation: https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md
run: |
"C:/Program Files (x86)/Inno Setup 6/iscc.exe" windows_installer_build_no_gui.iss
- name: Rename installer No Gui
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
run: |
mv build/Output/cloudfuse.exe build/Output/cloudfuse_no_gui_${VERSION}_windows_amd64.exe
- name: Cache windows installer
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
enableCrossOsArchive: true
path: build/Output/cloudfuse_${{ steps.get_version.outputs.VERSION }}_windows_amd64.exe
key: windows-cloudfuse-installer-${{ github.sha }}
- name: Cache windows installer No GUi
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
enableCrossOsArchive: true
path: build/Output/cloudfuse_no_gui_${{ steps.get_version.outputs.VERSION }}_windows_amd64.exe
key: windows-cloudfuse-no-gui-installer-${{ github.sha }}
release:
# Use GoReleaser to package and publish Linux releases along with the Windows installer
name: Release Binaries
needs: create-installer
runs-on: ubuntu-latest
env:
go: "1.24"
zig: 0.14.1
permissions:
contents: write
id-token: write
steps:
# libfuse-dev is required to build our command-line program and enable GoReleaser to build for ARM64
- name: Install Libfuse
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu libfuse-dev
# Get code and Go ready
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
persist-credentials: false
- name: Install Zig
env:
ZIG: ${{ env.zig }}
run: |
curl -L https://ziglang.org/download/${ZIG}/zig-x86_64-linux-${ZIG}.tar.xz -o zig.tar.xz
mkdir -p $HOME/.local/bin
tar -xf zig.tar.xz -C $HOME/.local/bin
echo "$HOME/.local/bin/zig-x86_64-linux-${ZIG}" >> $GITHUB_PATH
rm zig.tar.xz
- name: Install Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
with:
go-version: ${{ env.go }}
check-latest: true
cache: false
- name: Set up Cosign
uses: sigstore/cosign-installer@398d4b0eeef1380460a10c8013a76f728fb906ac # v3.9.1
- name: Set Version
id: get_version
run: echo "VERSION=${REF_NAME#v}" >> $GITHUB_OUTPUT
env:
REF_NAME: ${{ github.ref_name }}
# Get cached intermediate build products
- name: Restore cached Windows installer
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
enableCrossOsArchive: true
path: build/Output/cloudfuse_${{ steps.get_version.outputs.VERSION }}_windows_amd64.exe
key: windows-cloudfuse-installer-${{ github.sha }}
fail-on-cache-miss: true
# Get cached intermediate build products
- name: Restore cached Windows installer No Gui
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
enableCrossOsArchive: true
path: build/Output/cloudfuse_no_gui_${{ steps.get_version.outputs.VERSION }}_windows_amd64.exe
key: windows-cloudfuse-no-gui-installer-${{ github.sha }}
fail-on-cache-miss: true
- name: Restore Linux compiled GUI
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
path: gui/dist/cloudfuseGUI_Linux
key: Linux-compiled-gui-${{ hashFiles('gui/*.ui', 'gui/*.py') }}
fail-on-cache-miss: true
continue-on-error: false
- name: Restore Windows compiled GUI
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
enableCrossOsArchive: true
path: gui/dist/cloudfuseGUI_Windows
key: Windows-compiled-gui-${{ hashFiles('gui/*.ui', 'gui/*.py') }}
# the hash value comes out different on Linux vs Windows
# so we need to use restore-keys to match the Windows compiled GUI
# see documentation: https://github.com/actions/cache/blob/main/restore/README.md#inputs
restore-keys: Windows-compiled-gui-
continue-on-error: false
# Run GoReleaser (see .goreleaser.yaml)
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6
with:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}