Skip to content

Commit d06a8d3

Browse files
committed
ci: update appcast on builds
1 parent 96da5ae commit d06a8d3

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

.github/workflows/release.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ jobs:
4646
- name: Setup Nix
4747
uses: ./.github/actions/nix-devshell
4848

49+
- name: Authenticate to Google Cloud
50+
id: gcloud_auth
51+
uses: google-github-actions/auth@71f986410dfbc7added4569d411d040a91dc6935 # v2.1.8
52+
with:
53+
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_ID_PROVIDER }}
54+
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
55+
token_format: "access_token"
56+
4957
- name: Build
5058
env:
5159
APPLE_DEVELOPER_ID_PKCS12_B64: ${{ secrets.APPLE_DEVELOPER_ID_PKCS12_B64 }}
@@ -68,6 +76,11 @@ jobs:
6876
path: ${{ github.workspace }}/outputs/out
6977
retention-days: 7
7078

79+
- name: Get version string
80+
id: version_string
81+
run: |
82+
echo "versionstring=$(./scripts/version.sh)" >> "$GITHUB_OUTPUT"
83+
7184
# Upload to release in non-dry-run mode
7285
- name: Upload Release Assets
7386
if: ${{ !inputs.dryrun }}
@@ -76,6 +89,32 @@ jobs:
7689
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7790
RELEASE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || 'preview' }}
7891

92+
- name: Download Appcast
93+
# if: ${{ !inputs.dryrun }}
94+
run: |
95+
gsutil cp "gs://releases.coder.com/coder-desktop/mac/appcast.xml" ./oldappcast.xml
96+
97+
- name: Update Appcast
98+
# if: ${{ !inputs.dryrun }}
99+
run: |
100+
pushd scripts/update-appcast
101+
swift run update-appcast \
102+
-i ../../oldappcast.xml \
103+
-s "$out"/Coder-Desktop.pkg.sig \
104+
-v "$VERSION_STRING" \
105+
-o ../../appcast.xml
106+
-d "$VERSION_DESCRIPTION"
107+
popd
108+
env:
109+
VERSION_STRING: ${{ steps.version_string.outputs.versionstring }}
110+
VERSION_DESCRIPTION: ${{ github.event_name == 'release' && github.event.release.body || '' }}
111+
112+
113+
- name: Upload Appcast
114+
# if: ${{ !inputs.dryrun }}
115+
run: |
116+
gsutil -h "Cache-Control:no-cache,max-age=0" cp ./appcast.xml "gs://releases.coder.com/coder-desktop/mac/appcast.xml"
117+
79118
update-cask:
80119
name: Update homebrew-coder cask
81120
runs-on: ${{ github.repository_owner == 'coder' && 'depot-macos-latest' || 'macos-latest'}}

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
gh
5050
git
5151
gnumake
52+
google-cloud-sdk
5253
protobuf_28
5354
grpc-swift.packages.${system}.protoc-gen-grpc-swift
5455
grpc-swift.packages.${system}.protoc-gen-swift

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)