-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (155 loc) · 6.79 KB
/
Copy pathbuild.yml
File metadata and controls
168 lines (155 loc) · 6.79 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: "build"
on:
push:
branches:
- main
pull_request:
merge_group:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-24.04
- ubuntu-24.04-arm
- macos-latest
- macos-15-intel
steps:
- name: Checkout
uses: actions/checkout@v6
with:
# Make sure the actual branch is checked out when running on pull requests
ref: ${{ github.head_ref }}
repository: ${{github.event.pull_request.head.repo.full_name || github.repository }}
- name: Install libarchive, libcurl, and OpenSSL dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libarchive-dev libssl-dev libcurl4-openssl-dev
- name: Install libarchive, libcurl, and OpenSSL dependencies
if: runner.os == 'macOS'
run: |
brew update
brew install libarchive openssl curl
- name: Run make
run: |
make -j$(nproc)
- name: Prepare artifacts directory
run: |
mkdir -p outputs/bin
cp dist/zircon outputs/bin/
- name: Upload build artifacts
uses: actions/upload-artifact@v6
with:
path: outputs
name: zircon-${{ runner.os }}-${{ runner.arch }}-release
comment-artifacts:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Comment on PR with artifact links
uses: actions/github-script@v8
with:
script: |
const runId = context.runId;
const repoOwner = context.repo.owner;
const repoName = context.repo.repo;
const artifactUrl = `https://github.com/${repoOwner}/${repoName}/actions/runs/${runId}`;
const message = `🚀 **Build Artifacts**
Build artifacts have been generated for this PR across multiple platforms.
You can download the following artifacts from the [workflow run](${artifactUrl}):
- **Linux x64**: \`zircon-Linux-X64-release\`
- **Linux ARM64**: \`zircon-Linux-ARM64-release\`
- **macOS ARM64**: \`zircon-macOS-ARM64-release\`
- **macOS x64**: \`zircon-macOS-X64-release\`
If you use the [Zircon toolchain manager](https://github.com/zirco-lang/zircon), you can easily install the built artifacts using these downloaded packages:
\`\`\`bash
zircon self import ./zircon-Linux-X64-release.zip
\`\`\``;
// Find existing comment
const comments = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
const botComment = comments.data.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('🚀 **Build Artifacts**')
);
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
comment_id: botComment.id,
owner: context.repo.owner,
repo: context.repo.repo,
body: message
});
} else {
// Create new comment
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message
});
}
release:
# only on commits to main
needs: build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download X86 Linux build artifact
uses: actions/download-artifact@v7
with:
name: zircon-Linux-X64-release
path: Linux-X64
- name: Download ARM64 Linux build artifact
uses: actions/download-artifact@v7
with:
name: zircon-Linux-ARM64-release
path: Linux-ARM64
- name: Download X86 macOS build artifact
uses: actions/download-artifact@v7
with:
name: zircon-macOS-X64-release
path: macOS-X64
- name: Download ARM64 macOS build artifact
uses: actions/download-artifact@v7
with:
name: zircon-macOS-ARM64-release
path: macOS-ARM64
- name: Set executable permissions
run: |
chmod +x Linux-X64/bin/zircon
chmod +x Linux-ARM64/bin/zircon
chmod +x macOS-X64/bin/zircon
chmod +x macOS-ARM64/bin/zircon
- name: Create tar archives
run: |
tar -czf zircon-linux-x64.tar.gz -C Linux-X64 .
tar -czf zircon-linux-arm64.tar.gz -C Linux-ARM64 .
tar -czf zircon-macos-x64.tar.gz -C macOS-X64 .
tar -czf zircon-macos-arm64.tar.gz -C macOS-ARM64 .
- name: Update `nightly` release
uses: softprops/action-gh-release@v1
with:
tag_name: nightly
name: Latest Build
body: |
This is an automated build of the Zircon project from the `main` branch.
**Commit:** ${{ github.sha }}
**Date:** ${{ github.event.head_commit.timestamp }}
draft: false
prerelease: true
files: |
zircon-linux-x64.tar.gz
zircon-linux-arm64.tar.gz
zircon-macos-x64.tar.gz
zircon-macos-arm64.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}