170 lines
5.5 KiB
YAML
170 lines
5.5 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: 'Version to validate (e.g. 0.73.0).'
|
|
type: string
|
|
required: true
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: macos-latest
|
|
environment: release
|
|
outputs:
|
|
version: ${{ steps.ver.outputs.version }}
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/setup-go@v7
|
|
with:
|
|
go-version: stable
|
|
|
|
- name: Determine version
|
|
id: ver
|
|
run: |
|
|
if [ "${{ github.event_name }}" = "push" ]; then
|
|
v=${GITHUB_REF_NAME#v}
|
|
else
|
|
v='${{ inputs.version }}'
|
|
fi
|
|
echo "version=$v" >> "$GITHUB_OUTPUT"
|
|
echo "Resolved version: '$v'"
|
|
|
|
- name: Verify version consistency
|
|
run: |
|
|
set -e
|
|
V='${{ steps.ver.outputs.version }}'
|
|
R=$(echo "$V" | sed 's/\./\\./g')
|
|
grep -q "^${R}$" CHANGELOG.md
|
|
grep -qF "\"fzf ${V}\"" man/man1/fzf.1
|
|
grep -qF "\"fzf ${V}\"" man/man1/fzf-tmux.1
|
|
grep -qF "${V}" install
|
|
grep -qF "${V}" install.ps1
|
|
|
|
- name: Extract release notes
|
|
run: |
|
|
set -e
|
|
mkdir -p tmp
|
|
V='${{ steps.ver.outputs.version }}'
|
|
R=$(echo "$V" | sed 's/\./\\./g')
|
|
sed -n "/^${R}$/,/^[0-9]/p" CHANGELOG.md \
|
|
| tail -r | sed '1,/^ *$/d' | tail -r | sed '1,2d' \
|
|
| tee tmp/release-note
|
|
|
|
- name: Run goreleaser
|
|
uses: goreleaser/goreleaser-action@v7
|
|
with:
|
|
version: latest
|
|
args: >-
|
|
${{ github.event_name == 'push'
|
|
&& 'release --clean --release-notes tmp/release-note'
|
|
|| 'release --snapshot --clean --skip=publish' }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.RELEASE_PAT }}
|
|
MACOS_SIGN_P12: ${{ secrets.MACOS_SIGN_P12 }}
|
|
MACOS_SIGN_PASSWORD: ${{ secrets.MACOS_SIGN_PASSWORD }}
|
|
MACOS_NOTARY_ISSUER_ID: ${{ secrets.MACOS_NOTARY_ISSUER_ID }}
|
|
MACOS_NOTARY_KEY_ID: ${{ secrets.MACOS_NOTARY_KEY_ID }}
|
|
MACOS_NOTARY_KEY: ${{ secrets.MACOS_NOTARY_KEY }}
|
|
|
|
# For the msi job
|
|
- uses: actions/upload-artifact@v7
|
|
with:
|
|
name: windows-binaries
|
|
path: |
|
|
dist/*windows_amd64*/fzf.exe
|
|
dist/*windows_arm64*/fzf.exe
|
|
if-no-files-found: error
|
|
|
|
# winget's portable install runs fzf through a symlink that admin SSH
|
|
# sessions refuse to follow (#4943). The MSI installs a real file instead.
|
|
# WiX only runs on Windows.
|
|
msi:
|
|
needs: release
|
|
runs-on: windows-latest
|
|
env:
|
|
# MSI versions cannot have a suffix such as -rc1
|
|
BUILD_MSI: ${{ !contains(needs.release.outputs.version, '-') }}
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- uses: actions/download-artifact@v8
|
|
if: env.BUILD_MSI == 'true'
|
|
with:
|
|
name: windows-binaries
|
|
path: dist
|
|
|
|
- uses: actions/setup-dotnet@v6
|
|
if: env.BUILD_MSI == 'true'
|
|
with:
|
|
dotnet-version: '8.0.x'
|
|
|
|
# WiX 6 and later fall under the Open Source Maintenance Fee
|
|
- name: Install WiX
|
|
if: env.BUILD_MSI == 'true'
|
|
run: dotnet tool install --global wix --version 5.0.2
|
|
|
|
- name: Build Windows MSI installers
|
|
if: env.BUILD_MSI == 'true'
|
|
shell: bash
|
|
run: |
|
|
set -e
|
|
V='${{ needs.release.outputs.version }}'
|
|
for pair in "amd64:x64" "arm64:arm64"; do
|
|
goarch="${pair%%:*}"
|
|
wixarch="${pair##*:}"
|
|
bindir=$(dirname "$(find dist -type f -iname fzf.exe -path "*windows_${goarch}*" | head -n1)")
|
|
wix build wix/main.wxs -arch "$wixarch" -d Version="$V" -d BinDir="$bindir" -o "dist/fzf-${V}-windows_${goarch}.msi"
|
|
done
|
|
ls -la dist/*.msi
|
|
|
|
- uses: actions/upload-artifact@v7
|
|
if: env.BUILD_MSI == 'true'
|
|
with:
|
|
name: windows-msi
|
|
path: dist/*.msi
|
|
|
|
- name: Upload MSI installers and publish release
|
|
if: github.event_name == 'push'
|
|
shell: bash
|
|
run: |
|
|
set -e
|
|
V='${{ needs.release.outputs.version }}'
|
|
# A re-run would replace MSIs that a winget manifest may already
|
|
# reference, and submit to winget again
|
|
if [[ $(gh release view "v$V" --json isDraft --jq .isDraft) != true ]]; then
|
|
echo "::error::v$V is already published"
|
|
exit 1
|
|
fi
|
|
if [[ $BUILD_MSI == true ]]; then
|
|
sums="fzf_${V}_checksums.txt"
|
|
# Drop MSI lines from a previous run of this job
|
|
gh release download "v$V" -p "$sums" -O - | grep -v '\.msi$' > "dist/$sums"
|
|
# sha256sum on Windows may print '<hash> *<name>'
|
|
(cd dist && sha256sum fzf-*.msi) | sed 's/ \*/ /' >> "dist/$sums"
|
|
gh release upload "v$V" dist/*.msi "dist/$sums" --clobber
|
|
fi
|
|
gh release edit "v$V" --draft=false
|
|
env:
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
|
|
# Called directly because a release published with GITHUB_TOKEN does not
|
|
# trigger other workflows
|
|
winget:
|
|
needs: [release, msi]
|
|
if: github.event_name == 'push' && !contains(needs.release.outputs.version, '-')
|
|
uses: ./.github/workflows/winget.yml
|
|
with:
|
|
release-tag: v${{ needs.release.outputs.version }}
|
|
secrets:
|
|
WINGET_TOKEN: ${{ secrets.WINGET_TOKEN }}
|