-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (107 loc) · 3.66 KB
/
Copy pathci-release.yml
File metadata and controls
124 lines (107 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: CI and Release
on:
push:
branches:
- main
- release
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
test:
name: Build and Test
runs-on: macos-15
permissions:
contents: read
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Show Swift version
run: swift --version
- name: Build
run: swift build
- name: Test
run: swift test --enable-swift-testing --disable-xctest
build-release:
name: Build Release Binary (${{ matrix.arch }})
needs: test
if: github.ref == 'refs/heads/release'
runs-on: ${{ matrix.runner }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- arch: arm64
runner: macos-15
- arch: x86_64
runner: macos-15-intel
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Build release binary
run: swift build -c release --arch "${{ matrix.arch }}"
- name: Package binary
run: |
set -euo pipefail
mkdir -p "dist/devtranslator-macos-${{ matrix.arch }}"
cp ".build/${{ matrix.arch }}-apple-macosx/release/devtranslator" "dist/devtranslator-macos-${{ matrix.arch }}/devtranslator"
cp README.md LICENSE "dist/devtranslator-macos-${{ matrix.arch }}/"
tar -C "dist/devtranslator-macos-${{ matrix.arch }}" -czf "dist/devtranslator-macos-${{ matrix.arch }}.tar.gz" .
shasum -a 256 "dist/devtranslator-macos-${{ matrix.arch }}.tar.gz" > "dist/devtranslator-macos-${{ matrix.arch }}.tar.gz.sha256"
- name: Upload packaged binary
uses: actions/upload-artifact@v4
with:
name: devtranslator-macos-${{ matrix.arch }}
path: |
dist/devtranslator-macos-${{ matrix.arch }}.tar.gz
dist/devtranslator-macos-${{ matrix.arch }}.tar.gz.sha256
publish-release:
name: Publish GitHub Release
needs: build-release
if: github.ref == 'refs/heads/release'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download packaged binaries
uses: actions/download-artifact@v4
with:
path: dist
pattern: devtranslator-macos-*
merge-multiple: true
- name: Show release assets
run: ls -lah dist
- name: Publish release assets
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: latest
RELEASE_TARGET: ${{ github.sha }}
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -f "$RELEASE_TAG" "$RELEASE_TARGET"
git push origin "refs/tags/$RELEASE_TAG" --force
gh release view "$RELEASE_TAG" >/dev/null 2>&1 || \
gh release create "$RELEASE_TAG" \
--title "Latest" \
--notes "Latest DevTranslator build from the release branch." \
--verify-tag \
--latest
gh release edit "$RELEASE_TAG" \
--title "Latest" \
--notes "Latest DevTranslator build from the release branch." \
--latest
gh release upload "$RELEASE_TAG" \
dist/devtranslator-macos-arm64.tar.gz \
dist/devtranslator-macos-arm64.tar.gz.sha256 \
dist/devtranslator-macos-x86_64.tar.gz \
dist/devtranslator-macos-x86_64.tar.gz.sha256 \
--clobber