mirror of
https://github.com/goreleaser/nfpm
synced 2026-11-29 04:44:55 +01:00
macos-linux-build cross-compiles the test app and packages it as an installer package, an application bundle and a disk image, unsigned and signed with a throwaway certificate. Where the repository's Apple Developer ID identities are available it also signs with those. macos-verify takes those exact bytes to a macOS runner. The installer installs, upgrades, downgrades and refuses the packages, including ones with non-ASCII names and failing scripts; the bundles are unpacked and launched, the images mounted; pkgutil, codesign and the system trust stack check the signatures, and the signing certificate is compared by fingerprint. Both jobs run on pull requests as well as in the merge queue. macos-acceptance-tests reads all three formats back on Linux for both architectures, in the merge queue like the other structure tests. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
342 lines
14 KiB
YAML
342 lines
14 KiB
YAML
# https://taskfile.dev
|
|
|
|
version: "3"
|
|
|
|
env:
|
|
GO111MODULE: on
|
|
GOPROXY: https://proxy.golang.org,direct
|
|
|
|
tasks:
|
|
dev:
|
|
desc: Setup git hooks
|
|
cmds:
|
|
- git config core.hooksPath .githooks
|
|
|
|
setup:
|
|
desc: Install dependencies
|
|
cmds:
|
|
- go mod tidy
|
|
|
|
docker:setup:
|
|
desc: Setup Docker for multi-arch image builds
|
|
cmds:
|
|
- docker run --privileged --rm tonistiigi/binfmt --install all
|
|
|
|
build:
|
|
desc: Build the binary
|
|
sources:
|
|
- ./**/*.go
|
|
generates:
|
|
- ./nfpm
|
|
cmds:
|
|
- go build ./cmd/nfpm
|
|
|
|
acceptance:windows:package:
|
|
desc: Build packages for testing
|
|
vars:
|
|
SRC: "./testdata/acceptance/core.complex.yaml"
|
|
MSIX_SRC: "./testdata/acceptance/msix.basic.yaml"
|
|
cmds:
|
|
- mkdir -p ./dist
|
|
- go run ./cmd/nfpm/... pkg -f {{.SRC}} -p deb -t ./dist/foo.deb
|
|
- go run ./cmd/nfpm/... pkg -f {{.SRC}} -p rpm -t ./dist/foo.rpm
|
|
- go run ./cmd/nfpm/... pkg -f {{.SRC}} -p apk -t ./dist/foo.apk
|
|
- go run ./cmd/nfpm/... pkg -f {{.SRC}} -p archlinux -t ./dist/foo.pkg.tar.zst
|
|
- go run ./cmd/nfpm/... pkg -f {{.MSIX_SRC}} -p msix -t ./dist/foo.msix
|
|
|
|
acceptance:windows:install:
|
|
desc: Install packages built with package
|
|
cmds:
|
|
- docker run --rm --workdir /tmp -v $PWD/dist:/tmp fedora rpm --nosignature -ivh foo.rpm
|
|
- docker run --rm --workdir /tmp -v $PWD/dist:/tmp ubuntu dpkg -i foo.deb
|
|
- docker run --rm --workdir /tmp -v $PWD/dist:/tmp archlinux pacman --noconfirm -U foo.pkg.tar.zst
|
|
- docker run --rm --workdir /tmp -v $PWD/dist:/tmp alpine apk add --allow-untrusted foo.apk
|
|
|
|
acceptance:windows:package:msix:
|
|
desc: Build MSIX package for Windows install testing
|
|
platforms: [windows]
|
|
cmds:
|
|
- go build -o ./dist/testapp.exe ./testdata/acceptance/testapp/
|
|
- pwsh -ExecutionPolicy Bypass -File testdata/acceptance/create-test-cert.ps1
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/msix.install.yaml -p msix -t ./dist/foo.msix
|
|
- pwsh -ExecutionPolicy Bypass -File testdata/acceptance/sign-msix.ps1
|
|
|
|
acceptance:windows:install:msix:
|
|
desc: Install and verify MSIX package on Windows
|
|
platforms: [windows]
|
|
cmds:
|
|
- pwsh -ExecutionPolicy Bypass -File testdata/acceptance/install-msix.ps1
|
|
|
|
acceptance:windows:package:msi:
|
|
desc: Build MSI package for Windows install testing
|
|
platforms: [windows]
|
|
cmds:
|
|
- mkdir -p ./dist
|
|
- go build -o ./dist/testapp.exe ./testdata/acceptance/testapp/
|
|
- go build -ldflags="-X=main.message=nfpm-msi-v2-test-ok" -o ./dist/testapp-newer.exe ./testdata/acceptance/testapp/
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/msi.install.yaml -p msi -t ./dist/foo.msi
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/msi.upgrade.yaml -p msi -t ./dist/foo-upgrade.msi
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/msi.newer.yaml -p msi -t ./dist/foo-newer.msi
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/msi.downgrade.yaml -p msi -t ./dist/foo-downgrade.msi
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/msi.rollback.yaml -p msi -t ./dist/foo-rollback.msi
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/msi.user-latin.yaml -p msi -t ./dist/foo-user-latin.msi
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/msi.user-japanese.yaml -p msi -t ./dist/foo-user-japanese.msi
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/msi.user-cyrillic.yaml -p msi -t ./dist/foo-user-cyrillic.msi
|
|
- go run ./testdata/acceptance/msi-regressions/
|
|
|
|
acceptance:windows:install:msi:
|
|
desc: Install, upgrade, downgrade and remove MSI packages on Windows, and prove a failing script rolls back
|
|
platforms: [windows]
|
|
cmds:
|
|
- pwsh -ExecutionPolicy Bypass -File testdata/acceptance/install-msi.ps1 -Msi ./dist/foo.msi -Upgrade ./dist/foo-upgrade.msi -Newer ./dist/foo-newer.msi -Downgrade ./dist/foo-downgrade.msi -Rollback ./dist/foo-rollback.msi
|
|
- pwsh -ExecutionPolicy Bypass -File testdata/acceptance/verify-msi-regressions.ps1
|
|
|
|
acceptance:windows:install:msi:signed:
|
|
desc: Install, verify and remove the nfpm-signed MSI on Windows
|
|
platforms: [windows]
|
|
cmds:
|
|
- pwsh -ExecutionPolicy Bypass -File testdata/acceptance/install-msi.ps1 -Msi ./dist/foo.msi
|
|
|
|
acceptance:windows:install:msi:per-user:
|
|
desc: Verify Unicode metadata and install/remove MSI packages as a fresh standard user on a disposable Windows CI runner
|
|
platforms: [windows]
|
|
cmds:
|
|
- pwsh -ExecutionPolicy Bypass -File testdata/acceptance/verify-msi-per-user.ps1
|
|
|
|
acceptance:windows:package:signed:msi:
|
|
desc: Cross-compile the test app and build the nfpm-signed MSI package (runs on Linux/macOS)
|
|
env:
|
|
NFPM_MSI_PASSPHRASE: test123
|
|
cmds:
|
|
- mkdir -p ./dist
|
|
- ./testdata/acceptance/create-test-cert.sh
|
|
- GOOS=windows GOARCH=amd64 go build -o ./dist/testapp.exe ./testdata/acceptance/testapp/
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/msi.install.yaml -p msi -t ./dist/foo-unsigned.msi
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/msi.signed.yaml -p msi -t ./dist/foo.msi
|
|
|
|
acceptance:windows:verify:msi:signed:
|
|
desc: Trust the test cert and validate the nfpm-signed MSI with the real Windows trust stack
|
|
platforms: [windows]
|
|
cmds:
|
|
- pwsh -ExecutionPolicy Bypass -File testdata/acceptance/verify-signature.ps1 -Cert ./dist/test.cer -Signed ./dist/foo.msi -Unsigned ./dist/foo-unsigned.msi
|
|
|
|
acceptance:windows:package:signed:msix:
|
|
desc: Cross-compile the test app and build the nfpm-signed MSIX package (runs on Linux/macOS)
|
|
env:
|
|
NFPM_MSIX_PASSPHRASE: test123
|
|
cmds:
|
|
- mkdir -p ./dist
|
|
- ./testdata/acceptance/create-test-cert.sh
|
|
- GOOS=windows GOARCH=amd64 go build -o ./dist/testapp.exe ./testdata/acceptance/testapp/
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/msix.install.yaml -p msix -t ./dist/foo-unsigned.msix
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/msix.signed.yaml -p msix -t ./dist/foo.msix
|
|
|
|
acceptance:windows:verify:msix:signed:
|
|
desc: Trust the test cert and validate the nfpm-signed MSIX with the real Windows trust stack
|
|
platforms: [windows]
|
|
cmds:
|
|
- pwsh -ExecutionPolicy Bypass -File testdata/acceptance/verify-signature.ps1 -Cert ./dist/test.cer -Signed ./dist/foo.msix -Unsigned ./dist/foo-unsigned.msix
|
|
|
|
acceptance:macos:package:
|
|
desc: Cross-compile the test app and build the macOS app, dmg and pkg packages (runs on Linux/macOS)
|
|
vars:
|
|
ARCH: '{{default "arm64" .ARCH}}'
|
|
env:
|
|
NFPM_PKG_TEST_ARCH: "{{.ARCH}}"
|
|
NFPM_PASSPHRASE: test123
|
|
NFPM_MACOS_TEST_P12: ./dist/test.pfx
|
|
NFPM_MACOS_TEST_TIMESTAMP_URL: none
|
|
cmds:
|
|
- mkdir -p ./dist
|
|
- ./testdata/acceptance/create-test-cert.sh
|
|
- printf 'hello from nfpm\n' > './dist/héllo-世界.txt'
|
|
- GOOS=darwin GOARCH={{.ARCH}} go build -ldflags="-X=main.message=nfpm-pkg-v1-test-ok" -o ./dist/testapp ./testdata/acceptance/testapp/
|
|
- GOOS=darwin GOARCH={{.ARCH}} go build -ldflags="-X=main.message=nfpm-pkg-v2-test-ok" -o ./dist/testapp-newer ./testdata/acceptance/testapp/
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/pkg.install.yaml -p pkg -t ./dist/nfpm-pkg-test-v1.pkg
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/pkg.upgrade.yaml -p pkg -t ./dist/nfpm-pkg-test-v2.pkg
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/pkg.rollback.yaml -p pkg -t ./dist/nfpm-pkg-test-rollback.pkg
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/pkg.postinstall-fail.yaml -p pkg -t ./dist/nfpm-pkg-test-postfail.pkg
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/pkg.signed.yaml -p pkg -t ./dist/nfpm-pkg-test-signed.pkg
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/app.install.yaml -p app -t ./dist/nfpm-app-test.app.zip
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/app.signed.yaml -p app -t ./dist/nfpm-app-test-signed.app.zip
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/app.install.yaml -p dmg -t ./dist/nfpm-app-test.dmg
|
|
- go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/app.signed.yaml -p dmg -t ./dist/nfpm-app-test-signed.dmg
|
|
- go run ./testdata/acceptance/macos-fixtures/
|
|
|
|
acceptance:macos:package:developer-id:
|
|
desc: Sign the macOS packages with real Apple Developer ID identities (runs on Linux/macOS, needs the identities and Apple's timestamp service)
|
|
vars:
|
|
ARCH: '{{default "arm64" .ARCH}}'
|
|
requires:
|
|
vars: [APPLICATION_P12, INSTALLER_P12]
|
|
env:
|
|
NFPM_PKG_TEST_ARCH: "{{.ARCH}}"
|
|
# Empty on purpose: the signer then uses its default, Apple's service.
|
|
NFPM_MACOS_TEST_TIMESTAMP_URL: ""
|
|
cmds:
|
|
- mkdir -p ./dist/developer-id
|
|
- NFPM_MACOS_TEST_P12={{.INSTALLER_P12}} go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/pkg.signed.yaml -p pkg -t ./dist/developer-id/nfpm-pkg-test-signed.pkg
|
|
- NFPM_MACOS_TEST_P12={{.APPLICATION_P12}} go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/app.signed.yaml -p app -t ./dist/developer-id/nfpm-app-test-signed.app.zip
|
|
- NFPM_MACOS_TEST_P12={{.APPLICATION_P12}} go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/app.signed.yaml -p dmg -t ./dist/developer-id/nfpm-app-test-signed.dmg
|
|
# The certificates' fingerprints are public. The macOS job uses them to
|
|
# prove the signatures it accepts were made with these identities.
|
|
- ./testdata/acceptance/p12-fingerprint.sh {{.INSTALLER_P12}} > ./dist/developer-id/installer.sha256
|
|
- ./testdata/acceptance/p12-fingerprint.sh {{.APPLICATION_P12}} > ./dist/developer-id/application.sha256
|
|
|
|
acceptance:macos:install:pkg:
|
|
desc: Install, upgrade and verify the macOS installer packages on a disposable macOS CI runner
|
|
platforms: [darwin]
|
|
vars:
|
|
ARCH: '{{default "arm64" .ARCH}}'
|
|
env:
|
|
NFPM_PKG_TEST_ARCH: "{{.ARCH}}"
|
|
cmds:
|
|
- ./testdata/acceptance/install-pkg.sh
|
|
|
|
acceptance:macos:verify:app:
|
|
desc: Unpack, mount, launch and verify the macOS application bundles and disk images on macOS
|
|
platforms: [darwin]
|
|
vars:
|
|
ARCH: '{{default "arm64" .ARCH}}'
|
|
env:
|
|
NFPM_PKG_TEST_ARCH: "{{.ARCH}}"
|
|
cmds:
|
|
- ./testdata/acceptance/verify-app.sh
|
|
|
|
acceptance:pull:
|
|
desc: Pull acceptance test images
|
|
vars:
|
|
IMGS:
|
|
sh: grep FROM ./testdata/acceptance/*.dockerfile | cut -f2 -d' ' | grep -v min | grep -v test | sort | uniq
|
|
cmds:
|
|
- echo "{{.IMGS}}" | while read -r img; do docker pull $img; done
|
|
|
|
acceptance:
|
|
desc: Run acceptance tests
|
|
env:
|
|
LC_ALL: C
|
|
vars:
|
|
TEST_OPTIONS: '{{default "" .TEST_OPTIONS}}'
|
|
TEST_PATTERN: '{{default "." .TEST_PATTERN}}'
|
|
cmds:
|
|
- go test {{.TEST_OPTIONS}} -tags=acceptance -p 4 -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt acceptance_test.go -run {{.TEST_PATTERN}} -timeout=1h
|
|
|
|
test:
|
|
desc: Run unit tests
|
|
env:
|
|
LC_ALL: C
|
|
vars:
|
|
TEST_OPTIONS: '{{default "" .TEST_OPTIONS}}'
|
|
SOURCE_FILES: '{{default "./..." .SOURCE_FILES}}'
|
|
TEST_PATTERN: '{{default "." .TEST_PATTERN}}'
|
|
cmds:
|
|
- go test {{.TEST_OPTIONS}} -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt {{.SOURCE_FILES}} -run {{.TEST_PATTERN}} -timeout=5m
|
|
|
|
cover:
|
|
desc: Open the cover tool
|
|
cmds:
|
|
- go tool cover -html=coverage.txt
|
|
|
|
fmt:
|
|
desc: gofumpt all code
|
|
cmds:
|
|
- gofumpt -w -l .
|
|
|
|
ci:
|
|
desc: Run all CI steps
|
|
cmds:
|
|
- task: setup
|
|
- task: build
|
|
- task: test
|
|
- task: acceptance
|
|
|
|
default:
|
|
desc: Runs the default tasks
|
|
cmds:
|
|
- task: ci
|
|
|
|
schema:generate:
|
|
desc: Generate JSONSchema
|
|
cmds:
|
|
- go run ./cmd/nfpm/ schema -o ./www/static/schema.json
|
|
sources:
|
|
- nfpm.go
|
|
generates:
|
|
- ./www/static/schema.json
|
|
|
|
schema:validate:
|
|
desc: Validate JSONSchema
|
|
cmds:
|
|
- jv ./www/static/schema.json ./testdata/acceptance/*.yaml
|
|
sources:
|
|
- ./www/static/schema.json
|
|
- ./testdata/acceptance/*.yaml
|
|
|
|
docs:generate:
|
|
desc: Generate docs
|
|
cmds:
|
|
- ./scripts/cmd_docs.sh
|
|
sources:
|
|
- cmd/*.go
|
|
- files/*.go
|
|
- ./scripts/cmd_docs.sh
|
|
- CONTRIBUTING.md
|
|
generates:
|
|
- www/content/docs/cmd/*.md
|
|
- www/content/docs/contributing.md
|
|
|
|
docs:releases:
|
|
desc: Generate the latest file
|
|
cmds:
|
|
- ./scripts/pages/releases.sh
|
|
generates:
|
|
- www/static/latest
|
|
|
|
docs:imgs:
|
|
desc: Download and resize images
|
|
cmds:
|
|
- wget -O www/static/logo.png https://github.com/goreleaser/artwork/raw/master/goreleaserfundo.png
|
|
- wget -O www/static/favicon.svg https://raw.githubusercontent.com/goreleaser/artwork/refs/heads/master/goreleaser.svg
|
|
- convert www/static/logo.png -define icon:auto-resize=64,48,32,16 www/static/favicon.ico
|
|
- convert www/static/logo.png -resize x120 www/static/apple-touch-icon.png
|
|
- convert www/static/logo.png -resize x192 www/static/android-chrome-192x192.png
|
|
- convert www/static/logo.png -resize x512 www/static/android-chrome-512x512.png
|
|
- convert www/static/logo.png -resize x16 www/static/favicon-16x16.png
|
|
- convert www/static/logo.png -resize x32 www/static/favicon-32x32.png
|
|
|
|
docs:serve:
|
|
desc: Start documentation server
|
|
cmds:
|
|
- task: docs:generate
|
|
- cd www && hugo server --buildDrafts --bind 0.0.0.0 --port 8080
|
|
|
|
docs:build:
|
|
desc: Build docs
|
|
cmds:
|
|
- task: docs:generate
|
|
- cd www && hugo --minify
|
|
|
|
docs:test:
|
|
desc: Test docs with htmltest
|
|
cmds:
|
|
- task: docs:build
|
|
- htmltest www/public -c www/htmltest.yml
|
|
|
|
release:
|
|
desc: Create a new tag
|
|
vars:
|
|
NEXT:
|
|
sh: svu n
|
|
cmds:
|
|
- git tag {{.NEXT}}
|
|
- echo {{.NEXT}}
|
|
- git push origin --tags
|
|
|
|
release:watch:
|
|
vars:
|
|
RUN_ID:
|
|
sh: "gh run list --workflow=release.yml --limit 1 --json databaseId | jq -r '.[] | .databaseId'"
|
|
cmds:
|
|
- gh run watch {{.RUN_ID}}
|
|
- printf '\a'
|