Skip to content

TW-5118: fix AUR package build by including completions in release ar… #29

TW-5118: fix AUR package build by including completions in release ar…

TW-5118: fix AUR package build by including completions in release ar… #29

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., 1.2.3 or 1.3.0-rc.1). Do NOT include the "v" prefix.'
required: true
type: string
dry_run:
description: 'Dry run — build and validate without publishing'
required: false
type: boolean
default: false
permissions:
contents: write
jobs:
release:
runs-on: macos-latest
steps:
- name: Validate version format
if: github.event_name == 'workflow_dispatch'
env:
INPUT_VERSION: ${{ inputs.version }}
run: |
if [[ ! "$INPUT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
echo "::error::Invalid version format: '$INPUT_VERSION'. Expected semver (e.g., 1.2.3 or 1.3.0-rc.1)"
exit 1
fi
- name: Resolve version
id: version
env:
INPUT_VERSION: ${{ inputs.version }}
EVENT_NAME: ${{ github.event_name }}
run: |
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
echo "VERSION=v${INPUT_VERSION}" >> "$GITHUB_OUTPUT"
else
echo "VERSION=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
fi
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
- name: Check tag does not already exist
if: github.event_name == 'workflow_dispatch'
env:
TAG: ${{ steps.version.outputs.VERSION }}
run: |
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "::error::Tag $TAG already exists"
exit 1
fi
- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version: '1.26'
- name: Run tests
run: go test ./... -short
- name: Set up AUR SSH key
if: github.event_name == 'push'
env:
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
run: |
set -euo pipefail
if [ -z "$AUR_SSH_PRIVATE_KEY" ]; then
echo "::error::AUR_SSH_PRIVATE_KEY secret is required to publish the AUR package"
exit 1
fi
mkdir -p ~/.ssh
aur_key_path="$HOME/.ssh/aur_ed25519"
printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > "$aur_key_path"
chmod 600 "$aur_key_path"
aur_known_hosts="$(mktemp)"
ssh-keyscan -t ed25519 aur.archlinux.org > "$aur_known_hosts" 2>/dev/null
if ! ssh-keygen -lf "$aur_known_hosts" | grep -Fq 'SHA256:RFzBCUItH9LZS0cKB5UE6ceAYhBD5C8GeOBip8Z11+4'; then
echo "::error::AUR host key fingerprint did not match the expected ed25519 fingerprint"
exit 1
fi
cat "$aur_known_hosts" >> ~/.ssh/known_hosts
rm -f "$aur_known_hosts"
chmod 600 ~/.ssh/known_hosts
printf '%s\n' 'Host aur.archlinux.org' " IdentityFile $aur_key_path" ' User aur' >> ~/.ssh/config
echo "AUR_SSH_KEY_PATH=$aur_key_path" >> "$GITHUB_ENV"
- name: Validate release build
if: github.event_name == 'workflow_dispatch'
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6
with:
distribution: goreleaser
version: latest
args: release --clean --snapshot --skip=publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: ${{ steps.version.outputs.VERSION }}
- name: Create tag
if: github.event_name == 'workflow_dispatch' && !inputs.dry_run
env:
TAG: ${{ steps.version.outputs.VERSION }}
run: |
git tag "$TAG"
git push origin "$TAG"
- name: Run GoReleaser
if: github.event_name == 'push'
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: ${{ steps.version.outputs.VERSION }}
- name: Create DMG files
if: github.event_name == 'push'
env:
TAG: ${{ steps.version.outputs.VERSION }}
run: ./scripts/create-dmg.sh "$TAG"
- name: Upload DMG to release
if: github.event_name == 'push'
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2
with:
tag_name: ${{ steps.version.outputs.VERSION }}
files: |
dist/*.dmg
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker:
if: github.event_name == 'push'
needs: release
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Set up QEMU
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
- name: Log in to GHCR
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
with:
images: ghcr.io/nylas/cli
# 'latest' tag skipped for pre-release versions (tags containing '-')
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=raw,value=latest,enable=${{ !contains(github.ref_name, '-') }}
- name: Prepare release binaries
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref_name }}
run: |
set -euo pipefail
version="${TAG#v}"
mkdir -p linux/amd64 linux/arm64 /tmp/nylas-release
for i in 1 2 3 4 5; do
rm -f /tmp/nylas-release/*.tar.gz
gh release download "$TAG" \
--pattern "nylas_${version}_linux_amd64.tar.gz" \
--pattern "nylas_${version}_linux_arm64.tar.gz" \
--dir /tmp/nylas-release || true
[ -f "/tmp/nylas-release/nylas_${version}_linux_amd64.tar.gz" ] \
&& [ -f "/tmp/nylas-release/nylas_${version}_linux_arm64.tar.gz" ] \
&& break
echo "Attempt $i: not all release assets ready, retrying in 15s..."
sleep 15
done
if [ ! -f "/tmp/nylas-release/nylas_${version}_linux_amd64.tar.gz" ] \
|| [ ! -f "/tmp/nylas-release/nylas_${version}_linux_arm64.tar.gz" ]; then
echo "::error::Failed to download both Linux release assets after 5 attempts"
exit 1
fi
tar -xzf "/tmp/nylas-release/nylas_${version}_linux_amd64.tar.gz" -C linux/amd64 nylas
tar -xzf "/tmp/nylas-release/nylas_${version}_linux_arm64.tar.gz" -C linux/arm64 nylas
test -x linux/amd64/nylas || { echo "::error::linux/amd64/nylas is missing or not executable"; exit 1; }
test -x linux/arm64/nylas || { echo "::error::linux/arm64/nylas is missing or not executable"; exit 1; }
- name: Build and push Docker image
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
with:
context: .
target: goreleaser
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}