Skip to content

Commit 93e7a8f

Browse files
ci: download mutagen binary into resources (#103)
Closes #60
1 parent 6f6049e commit 93e7a8f

File tree

5 files changed

+54
-6
lines changed

5 files changed

+54
-6
lines changed

.github/workflows/release.yml

+19-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ on:
77
release:
88
types: [published]
99

10+
workflow_dispatch:
11+
inputs:
12+
dryrun:
13+
description: 'Run in dry-run mode (upload as artifact instead of release asset)'
14+
required: true
15+
type: boolean
16+
default: false
1017
permissions: {}
1118

1219
# Cancel in-progress runs for when multiple PRs get merged
@@ -51,7 +58,18 @@ jobs:
5158
EXT_PROF: ${{ secrets.CODER_DESKTOP_EXTENSION_PROVISIONPROFILE_B64 }}
5259
run: make release
5360

61+
# Upload as artifact in dry-run mode
62+
- name: Upload Build Artifact
63+
if: ${{ inputs.dryrun }}
64+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
65+
with:
66+
name: coder-desktop-build
67+
path: ${{ github.workspace }}/outputs/out
68+
retention-days: 7
69+
70+
# Upload to release in non-dry-run mode
5471
- name: Upload Release Assets
72+
if: ${{ !inputs.dryrun }}
5573
run: gh release upload "$RELEASE_TAG" "$out"/* --clobber
5674
env:
5775
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -60,7 +78,7 @@ jobs:
6078
update-cask:
6179
name: Update homebrew-coder cask
6280
runs-on: ${{ github.repository_owner == 'coder' && 'depot-macos-latest' || 'macos-latest'}}
63-
if: ${{ github.repository_owner == 'coder' }}
81+
if: ${{ github.repository_owner == 'coder' && !inputs.dryrun }}
6482
needs: build
6583
steps:
6684
- name: Checkout

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,6 @@ release/
302302

303303
# marker files
304304
.fl5C1A396C
305+
306+
# Embedded mutagen resources
307+
Coder Desktop/Resources/mutagen-*

Coder Desktop/Resources/.gitkeep

Whitespace-only changes.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v0.18.1

Makefile

+31-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Use bash, and immediately exit on failure
2+
SHELL := bash
3+
.SHELLFLAGS := -ceu
4+
5+
# This doesn't work on directories.
6+
# See https://stackoverflow.com/questions/25752543/make-delete-on-error-for-directory-targets
7+
.DELETE_ON_ERROR:
8+
19
ifdef CI
210
LINTFLAGS := --reporter github-actions-logging
311
FMTFLAGS := --lint --reporter github-actions-log
@@ -11,18 +19,26 @@ XCPROJECT := Coder\ Desktop/Coder\ Desktop.xcodeproj
1119
SCHEME := Coder\ Desktop
1220
SWIFT_VERSION := 6.0
1321

22+
MUTAGEN_RESOURCES := mutagen-agents.tar.gz mutagen-darwin-arm64 mutagen-darwin-amd64
23+
ifndef MUTAGEN_VERSION
24+
MUTAGEN_VERSION:=$(shell grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$$' $(PROJECT)/Resources/.mutagenversion)
25+
endif
26+
ifeq ($(strip $(MUTAGEN_VERSION)),)
27+
$(error MUTAGEN_VERSION must be a valid version)
28+
endif
29+
1430
ifndef CURRENT_PROJECT_VERSION
15-
CURRENT_PROJECT_VERSION:=$(shell git describe --match 'v[0-9]*' --dirty='.devel' --always --tags)
31+
CURRENT_PROJECT_VERSION:=$(shell git describe --match 'v[0-9]*' --dirty='.devel' --always --tags)
1632
endif
1733
ifeq ($(strip $(CURRENT_PROJECT_VERSION)),)
18-
$(error CURRENT_PROJECT_VERSION cannot be empty)
34+
$(error CURRENT_PROJECT_VERSION cannot be empty)
1935
endif
2036

2137
ifndef MARKETING_VERSION
22-
MARKETING_VERSION:=$(shell git describe --match 'v[0-9]*' --tags --abbrev=0 | sed 's/^v//' | sed 's/-.*$$//')
38+
MARKETING_VERSION:=$(shell git describe --match 'v[0-9]*' --tags --abbrev=0 | sed 's/^v//' | sed 's/-.*$$//')
2339
endif
2440
ifeq ($(strip $(MARKETING_VERSION)),)
25-
$(error MARKETING_VERSION cannot be empty)
41+
$(error MARKETING_VERSION cannot be empty)
2642
endif
2743

2844
# Define the keychain file name first
@@ -32,10 +48,16 @@ APP_SIGNING_KEYCHAIN := $(if $(wildcard $(KEYCHAIN_FILE)),$(shell realpath $(KEY
3248

3349
.PHONY: setup
3450
setup: \
51+
$(addprefix $(PROJECT)/Resources/,$(MUTAGEN_RESOURCES)) \
3552
$(XCPROJECT) \
3653
$(PROJECT)/VPNLib/vpn.pb.swift \
3754
$(PROJECT)/VPNLib/FileSync/daemon.pb.swift
3855

56+
# Mutagen resources
57+
$(addprefix $(PROJECT)/Resources/,$(MUTAGEN_RESOURCES)): $(PROJECT)/Resources/.mutagenversion
58+
curl -sL "https://storage.googleapis.com/coder-desktop/mutagen/$(MUTAGEN_VERSION)/$$(basename "$@")" -o "$@"
59+
chmod +x "$@"
60+
3961
$(XCPROJECT): $(PROJECT)/project.yml
4062
cd $(PROJECT); \
4163
SWIFT_VERSION=$(SWIFT_VERSION) \
@@ -113,7 +135,7 @@ lint/actions: ## Lint GitHub Actions
113135
zizmor .
114136

115137
.PHONY: clean
116-
clean: clean/project clean/keychain clean/build ## Clean project and artifacts
138+
clean: clean/project clean/keychain clean/build clean/mutagen ## Clean project and artifacts
117139

118140
.PHONY: clean/project
119141
clean/project:
@@ -136,6 +158,10 @@ clean/keychain:
136158
clean/build:
137159
rm -rf build/ release/ $$out
138160

161+
.PHONY: clean/mutagen
162+
clean/mutagen:
163+
find $(PROJECT)/Resources -name 'mutagen-*' -delete
164+
139165
.PHONY: proto
140166
proto: $(PROJECT)/VPNLib/vpn.pb.swift $(PROJECT)/VPNLib/FileSync/daemon.pb.swift ## Generate Swift files from protobufs
141167

0 commit comments

Comments
 (0)