Skip to content

Commit 3c72ff4

Browse files
ci: update appcast on builds (#174)
Fourth PR for #47. Dry-run worked! https://releases.coder.com/coder-desktop/mac/appcast.xml
1 parent 46074e2 commit 3c72ff4

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

.github/workflows/release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
permissions:
3131
# To upload assets to the release
3232
contents: write
33+
# for GCP auth
34+
id-token: write
3335
steps:
3436
- name: Checkout
3537
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -46,6 +48,17 @@ jobs:
4648
- name: Setup Nix
4749
uses: ./.github/actions/nix-devshell
4850

51+
- name: Authenticate to Google Cloud
52+
id: gcloud_auth
53+
uses: google-github-actions/auth@71f986410dfbc7added4569d411d040a91dc6935 # v2.1.8
54+
with:
55+
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_ID_PROVIDER }}
56+
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
57+
token_format: "access_token"
58+
59+
- name: Setup GCloud SDK
60+
uses: google-github-actions/setup-gcloud@77e7a554d41e2ee56fc945c52dfd3f33d12def9a # v2.1.4
61+
4962
- name: Build
5063
env:
5164
APPLE_DEVELOPER_ID_PKCS12_B64: ${{ secrets.APPLE_DEVELOPER_ID_PKCS12_B64 }}
@@ -76,6 +89,22 @@ jobs:
7689
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7790
RELEASE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || 'preview' }}
7891

92+
- name: Update Appcast
93+
if: ${{ !inputs.dryrun }}
94+
run: |
95+
gsutil cp "gs://releases.coder.com/coder-desktop/mac/appcast.xml" ./oldappcast.xml
96+
pushd scripts/update-appcast
97+
swift run update-appcast \
98+
-i ../../oldappcast.xml \
99+
-s "$out"/Coder-Desktop.pkg.sig \
100+
-v "$(../version.sh)" \
101+
-o ../../appcast.xml \
102+
-d "$VERSION_DESCRIPTION"
103+
popd
104+
gsutil -h "Cache-Control:no-cache,max-age=0" cp ./appcast.xml "gs://releases.coder.com/coder-desktop/mac/appcast.xml"
105+
env:
106+
VERSION_DESCRIPTION: ${{ github.event_name == 'release' && github.event.release.body || '' }}
107+
79108
update-cask:
80109
name: Update homebrew-coder cask
81110
runs-on: ${{ github.repository_owner == 'coder' && 'depot-macos-latest' || 'macos-latest'}}

flake.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@
5959
xcpretty
6060
zizmor
6161
];
62+
shellHook = ''
63+
# Copied from https://github.com/ghostty-org/ghostty/blob/c4088f0c73af1c153c743fc006637cc76c1ee127/nix/devShell.nix#L189-L199
64+
# We want to rely on the system Xcode tools in CI!
65+
unset SDKROOT
66+
unset DEVELOPER_DIR
67+
# We need to remove the nix "xcrun" from the PATH.
68+
export PATH=$(echo "$PATH" | awk -v RS=: -v ORS=: '$0 !~ /xcrun/ || $0 == "/usr/bin" {print}' | sed 's/:$//')
69+
'';
6270
};
6371

6472
default = pkgs.mkShellNoCC {

scripts/update-appcast/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import PackageDescription
66
let package = Package(
77
name: "update-appcast",
88
platforms: [
9-
.macOS(.v15),
9+
.macOS(.v14),
1010
],
1111
dependencies: [
1212
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.0"),

scripts/update-appcast/Sources/main.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct UpdateAppcast: AsyncParsableCommand {
6868
}
6969

7070
let xmlData = try Data(contentsOf: URL(fileURLWithPath: input))
71-
let doc = try XMLDocument(data: xmlData, options: .nodePrettyPrint)
71+
let doc = try XMLDocument(data: xmlData, options: [.nodePrettyPrint, .nodePreserveAll])
7272

7373
guard let channelElem = try doc.nodes(forXPath: "/rss/channel").first as? XMLElement else {
7474
throw RuntimeError("<channel> element not found in appcast.")
@@ -98,7 +98,7 @@ struct UpdateAppcast: AsyncParsableCommand {
9898
item.addChild(XMLElement(name: "title", stringValue: "Preview"))
9999
}
100100

101-
if let description {
101+
if let description, !description.isEmpty {
102102
let description = description.replacingOccurrences(of: #"\r\n"#, with: "\n")
103103
let descriptionDoc: Document
104104
do {
@@ -143,7 +143,7 @@ struct UpdateAppcast: AsyncParsableCommand {
143143

144144
channelElem.insertChild(item, at: insertionIndex)
145145

146-
let outputStr = doc.xmlString(options: [.nodePrettyPrint]) + "\n"
146+
let outputStr = doc.xmlString(options: [.nodePrettyPrint, .nodePreserveAll]) + "\n"
147147
try outputStr.write(to: URL(fileURLWithPath: output), atomically: true, encoding: .utf8)
148148
}
149149

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy