Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit d3e4652

Browse files
authored
Add GitHub Action workflows for release automation (#190)
* Add release workflow * Add deploy workflow * A release is a prerelease if its tag contains a dash * Use matrix strategy to make workflow easier to update for new versions of Swift * Make swift-doc target non-PHONY * Create release artifacts compatible with Homebrew bottles * Use SwiftDocOrg/update-homebrew-formula-action
1 parent 9760f29 commit d3e4652

File tree

4 files changed

+159
-12
lines changed

4 files changed

+159
-12
lines changed

.github/workflows/deploy.yml

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Deploy
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
8+
jobs:
9+
macos:
10+
name: Upload macOS Catalina release binary
11+
runs-on: macos-10.15
12+
13+
strategy:
14+
matrix:
15+
xcode:
16+
- "12" # Swift 5.3
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
with:
22+
ref: ${{ github.event.release.tag_name }}
23+
- name: Build and Package
24+
run: |
25+
make swift-doc
26+
tar -cf swift-doc-${{ github.event.release.tag_name }}.catalina.bottle.tar swift-doc
27+
gzip -f swift-doc-${{ github.event.release.tag_name }}.catalina.bottle.tar
28+
env:
29+
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
30+
- name: Upload
31+
uses: actions/[email protected]
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
with:
35+
upload_url: ${{ github.event.release.upload_url }}
36+
asset_path: ./swift-doc
37+
asset_name: swift-doc-${{ github.event.release.tag_name }}.catalina.bottle.tar.gz
38+
asset_content_type: application/gzip
39+
40+
linux:
41+
name: Upload Linux release binary
42+
43+
runs-on: ubuntu-latest
44+
45+
strategy:
46+
matrix:
47+
swift: ["5.3"]
48+
49+
container:
50+
image: swift:${{ matrix.swift }}
51+
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v2
55+
with:
56+
ref: ${{ github.event.release.tag_name }}
57+
- name: Install System Dependencies
58+
run: |
59+
apt-get update
60+
apt-get install -y libxml2-dev graphviz
61+
- name: Build and Package
62+
run: |
63+
make swift-doc
64+
tar -cf swift-doc-${{ github.event.release.tag_name }}.linux.bottle.tar.gz swift-doc
65+
gzip -f swift-doc-${{ github.event.release.tag_name }}.linux.bottle.tar.gz
66+
- name: Upload
67+
uses: actions/[email protected]
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
with:
71+
upload_url: ${{ github.event.release.upload_url }}
72+
asset_path: ./swift-doc
73+
asset_name: swift-doc-${{ github.event.release.tag_name }}.linux.bottle.tar.gz
74+
asset_content_type: application/gzip
75+
76+
homebrew:
77+
name: Update Homebrew formula
78+
runs-on: ubuntu-latest
79+
needs: [macos, linux]
80+
steps:
81+
- uses: SwiftDocOrg/update-homebrew-formula-action@main
82+
with:
83+
repository: SwiftDocOrg/swift-doc
84+
tap: SwiftDocOrg/homebrew-formulae
85+
formula: Formula/swift-doc.rb
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
89+
docker:
90+
name: Build and push Docker container
91+
92+
runs-on: ubuntu-latest
93+
94+
steps:
95+
- name: Checkout
96+
uses: actions/checkout@v2
97+
with:
98+
ref: ${{ github.event.release.tag_name }}
99+
- name: Set up QEMU
100+
uses: docker/setup-qemu-action@v1
101+
- name: Set up Docker Buildx
102+
uses: docker/setup-buildx-action@v1
103+
- name: Login to DockerHub
104+
uses: docker/login-action@v1
105+
with:
106+
username: ${{ secrets.DOCKERHUB_USERNAME }}
107+
password: ${{ secrets.DOCKERHUB_TOKEN }}
108+
- name: Build and push
109+
uses: docker/build-push-action@v2
110+
with:
111+
context: .
112+
file: ./Dockerfile
113+
platforms: linux/amd64
114+
push: true
115+
tags: |
116+
swiftdoc/swift-doc:latest
117+
swiftdoc/swift-doc:${{ github.event.release.tag_name }}

.github/workflows/release.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "*.*.*"
7+
8+
jobs:
9+
release:
10+
name: Create a release on GitHub
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
- name: Get Changelog Entries
18+
id: changelog
19+
uses: mindsers/changelog-reader-action@v2
20+
with:
21+
version: ${{ github.ref }}
22+
path: ./Changelog.md
23+
- name: Create Release
24+
uses: actions/create-release@v1
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
with:
28+
tag_name: ${{ github.ref }}
29+
release_name: ${{ github.ref }}
30+
body: ${{ steps.changelog.outputs.changes }}
31+
draft: false
32+
prerelease: contains(github.ref, '-')

Makefile

+6-8
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,17 @@ REPODIR = $(shell pwd)
88
BUILDDIR = $(REPODIR)/.build
99
SOURCES = $(wildcard $(srcdir)/**/*.swift)
1010

11-
.DEFAULT_GOAL = all
12-
13-
.PHONY: all
14-
all: swift-doc
15-
16-
swift-doc: $(SOURCES)
11+
$(BUILDDIR)/release/swift-doc: $(SOURCES)
1712
@swift build \
1813
-c release \
1914
--disable-sandbox \
2015
--build-path "$(BUILDDIR)"
2116

17+
swift-doc: $(BUILDDIR)/release/swift-doc
18+
@cp $< $@
19+
2220
.PHONY: install
23-
install: swift-doc
21+
install: $(BUILDDIR)/release/swift-doc
2422
@install -d "$(bindir)"
2523
@install "$(BUILDDIR)/release/swift-doc" "$(bindir)"
2624

@@ -33,5 +31,5 @@ distclean:
3331
@rm -f $(BUILDDIR)/release
3432

3533
.PHONY: clean
36-
clean: distclean
34+
clean:
3735
@rm -rf $(BUILDDIR)

Package.resolved

+4-4
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@
8686
"package": "SwiftSyntax",
8787
"repositoryURL": "https://github.com/apple/swift-syntax.git",
8888
"state": {
89-
"branch": "0.50200.0",
90-
"revision": "0688b9cfc4c3dd234e4f55f1f056b2affc849873",
89+
"branch": "0.50300.0",
90+
"revision": "844574d683f53d0737a9c6d706c3ef31ed2955eb",
9191
"version": null
9292
}
9393
},
@@ -113,8 +113,8 @@
113113
"package": "SwiftSyntaxHighlighter",
114114
"repositoryURL": "https://github.com/NSHipster/SwiftSyntaxHighlighter.git",
115115
"state": {
116-
"branch": "1.0.0",
117-
"revision": "4a20d10bba17241b66650d99081801536146b43c",
116+
"branch": "1.1.0",
117+
"revision": "b23b80be3032916dd5aefe9c621be25f75f3681f",
118118
"version": null
119119
}
120120
}

0 commit comments

Comments
 (0)