-
Notifications
You must be signed in to change notification settings - Fork 4
131 lines (113 loc) · 3.74 KB
/
release.yml
File metadata and controls
131 lines (113 loc) · 3.74 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
125
126
127
128
129
130
131
name: Build and Release Binaries
permissions:
contents: write
on:
release:
types: [published]
workflow_dispatch:
inputs:
ref:
description: 'Git ref to build (tag or branch)'
required: true
type: string
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: darwin-arm64
os: macos-latest
crystal_arch: aarch64
- target: linux-x86_64
os: ubuntu-latest
crystal_arch: x86_64
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ github.event.release.tag_name || github.event.inputs.ref }}
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
with:
crystal: latest
- name: Install dependencies
run: |
if [ -f shard.lock ]; then
shards install --production
else
shards install
fi
- name: Build binaries (Linux x86_64)
if: matrix.target == 'linux-x86_64'
run: |
crystal build src/amber_cli.cr -o amber --release --static
crystal build src/amber_lsp.cr -o amber-lsp --release --static
- name: Build binaries (macOS ARM64)
if: matrix.target == 'darwin-arm64'
run: |
crystal build src/amber_cli.cr -o amber --release
crystal build src/amber_lsp.cr -o amber-lsp --release
- name: Verify binaries
run: |
file amber
./amber --version
file amber-lsp
test -x amber-lsp
- name: Create archive
run: |
mkdir -p dist
tar -czf dist/amber_cli-${{ matrix.target }}.tar.gz amber amber-lsp
- name: Calculate checksum
id: checksum
run: |
cd dist
if command -v sha256sum >/dev/null 2>&1; then
sha256sum amber_cli-${{ matrix.target }}.tar.gz > amber_cli-${{ matrix.target }}.tar.gz.sha256
else
shasum -a 256 amber_cli-${{ matrix.target }}.tar.gz > amber_cli-${{ matrix.target }}.tar.gz.sha256
fi
echo "sha256=$(cat amber_cli-${{ matrix.target }}.tar.gz.sha256 | cut -d' ' -f1)" >> $GITHUB_OUTPUT
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: amber_cli-${{ matrix.target }}
path: |
dist/amber_cli-${{ matrix.target }}.tar.gz
dist/amber_cli-${{ matrix.target }}.tar.gz.sha256
upload-assets:
name: Upload Release Assets
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
- name: Upload release assets
uses: softprops/action-gh-release@v3
with:
files: |
artifacts/amber_cli-darwin-arm64/dist/amber_cli-darwin-arm64.tar.gz
artifacts/amber_cli-darwin-arm64/dist/amber_cli-darwin-arm64.tar.gz.sha256
artifacts/amber_cli-linux-x86_64/dist/amber_cli-linux-x86_64.tar.gz
artifacts/amber_cli-linux-x86_64/dist/amber_cli-linux-x86_64.tar.gz.sha256
tag_name: ${{ github.event.release.tag_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
notify-homebrew:
name: Notify Homebrew Tap
needs: upload-assets
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v4
with:
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
repository: amberframework/homebrew-amber_cli
event-type: release-published
client-payload: '{"version": "${{ github.event.release.tag_name }}"}'