Skip to content

Commit 33ca7b5

Browse files
authored
Switch tests and releases to GitHub Actions (#311)
1 parent 9c196b6 commit 33ca7b5

File tree

3 files changed

+68
-26
lines changed

3 files changed

+68
-26
lines changed

.github/workflows/release.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
on:
2+
release:
3+
types: [published]
4+
name: Upload Release Asset
5+
jobs:
6+
release:
7+
name: Upload Release Asset
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Install Go
11+
uses: actions/setup-go@v2
12+
with:
13+
go-version: 1.x
14+
- name: Checkout repository
15+
uses: actions/checkout@v2
16+
- name: Build binaries
17+
run: |
18+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "mkcert-$(git describe --tags)-linux-amd64" -ldflags "-X main.Version=$(git describe --tags)"
19+
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -o "mkcert-$(git describe --tags)-linux-arm" -ldflags "-X main.Version=$(git describe --tags)"
20+
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o "mkcert-$(git describe --tags)-linux-arm64" -ldflags "-X main.Version=$(git describe --tags)"
21+
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o "mkcert-$(git describe --tags)-darwin-amd64" -ldflags "-X main.Version=$(git describe --tags)"
22+
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o "mkcert-$(git describe --tags)-windows-amd64.exe" -ldflags "-X main.Version=$(git describe --tags)"
23+
- name: Upload release artifacts
24+
uses: actions/github-script@v3
25+
with:
26+
github-token: ${{ secrets.GITHUB_TOKEN }}
27+
script: |
28+
const fs = require("fs").promises;
29+
const { repo: { owner, repo }, sha } = context;
30+
31+
const release = await github.repos.getReleaseByTag({
32+
owner, repo,
33+
tag: process.env.GITHUB_REF.replace("refs/tags/", ""),
34+
});
35+
console.log("Release:", { release });
36+
37+
for (let file of await fs.readdir(".")) {
38+
if (!file.startsWith("mkcert-")) continue;
39+
console.log("Uploading", file);
40+
await github.repos.uploadReleaseAsset({
41+
owner, repo,
42+
release_id: release.data.id,
43+
name: file,
44+
data: await fs.readFile(file),
45+
});
46+
}

.github/workflows/test.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
on: [push, pull_request]
2+
name: Test
3+
jobs:
4+
test:
5+
name: Go tests
6+
strategy:
7+
fail-fast: false
8+
matrix:
9+
go: [1.14.x, 1.x]
10+
os: [ubuntu-latest, macos-latest, windows-latest]
11+
runs-on: ${{ matrix.os }}
12+
steps:
13+
- name: Install Go ${{ matrix.go }}
14+
uses: actions/setup-go@v2
15+
with:
16+
go-version: ${{ matrix.go }}
17+
- name: Checkout repository
18+
uses: actions/checkout@v2
19+
- name: Run analyses
20+
run: go run analysis.go ./...
21+
- name: Run tests
22+
run: go test -race ./...

.travis.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)