-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (111 loc) · 4.4 KB
/
build.yml
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
name: Build and Release
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
architecture: [amd64, arm64]
zig: [0.13.0]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: ${{ matrix.zig }}
- name: Setup Variables
id: vars
run: |
# Get the version and app name from the build.zig.zon file
VERSION=$(grep '.version' build.zig.zon | sed 's/.*= "\(.*\)",/\1/')
APP_NAME=$(grep '.name' build.zig.zon | sed 's/.*= "\(.*\)",/\1/')
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "APP_NAME=$APP_NAME" >> $GITHUB_OUTPUT
echo "DEB_FILENAME=${APP_NAME}_${VERSION}_${{ matrix.architecture }}.deb" >> $GITHUB_OUTPUT
# Get the commit hash of the last tag and the current tag
CURRENT_TAG=$(git describe --tags --abbrev=0)
PREVIOUS_TAG=$(git describe --tags --abbrev=0 --tags $(git rev-list -n 1 $CURRENT_TAG^))
echo "LAST_TAG_COMMIT_HASH=$(git rev-parse --short $(git rev-list -n 1 $PREVIOUS_TAG))" >> $GITHUB_OUTPUT
echo "COMMIT_HASH=$(git rev-parse --short $(git rev-list -n 1 $CURRENT_TAG))" >> $GITHUB_OUTPUT
- name: Build project
run: ./scripts/build.sh ${{ matrix.architecture }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ steps.vars.outputs.DEB_FILENAME }}
path: debs/${{ steps.vars.outputs.DEB_FILENAME }}
outputs:
version: ${{ steps.vars.outputs.VERSION }}
app_name: ${{ steps.vars.outputs.APP_NAME }}
deb_filename: ${{ steps.vars.outputs.DEB_FILENAME }}
last_tag_commit_hash: ${{ steps.vars.outputs.LAST_TAG_COMMIT_HASH }}
commit_hash: ${{ steps.vars.outputs.COMMIT_HASH }}
release:
needs: build
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Setup paths and variables
id: setup
run: |
mkdir -p ~/debs
echo "AMD_DEB_FILENAME=${{ needs.build.outputs.app_name }}_${{ needs.build.outputs.version }}_amd64.deb" >> $GITHUB_OUTPUT
echo "ARM_DEB_FILENAME=${{ needs.build.outputs.app_name }}_${{ needs.build.outputs.version }}_arm64.deb" >> $GITHUB_OUTPUT
- name: Download AMD Artifact
uses: actions/download-artifact@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ steps.setup.outputs.AMD_DEB_FILENAME }}
path: ~/debs
- name: Generate AMD SHA256 Checksum
id: sha256_amd
run: |
cd ~/debs
sha256sum ${{ steps.setup.outputs.AMD_DEB_FILENAME }} > ${{ steps.setup.outputs.AMD_DEB_FILENAME }}.sha256
echo "SHA256=$(cat ${{ steps.setup.outputs.AMD_DEB_FILENAME }}.sha256)" >> $GITHUB_OUTPUT
- name: Download ARM Artifact
uses: actions/download-artifact@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ steps.setup.outputs.ARM_DEB_FILENAME }}
path: ~/debs
- name: Generate ARM SHA256 Checksum
id: sha256_arm
run: |
cd ~/debs
sha256sum ${{ steps.setup.outputs.ARM_DEB_FILENAME }} > ${{ steps.setup.outputs.ARM_DEB_FILENAME }}.sha256
echo "SHA256=$(cat ${{ steps.setup.outputs.ARM_DEB_FILENAME }}.sha256)" >> $GITHUB_OUTPUT
- name: Move artifacts
run: |
mv ~/debs release
- name: Publish Release
uses: softprops/action-gh-release@v2
with:
files: release/*
name: ${{ needs.build.outputs.app_name }} v${{ needs.build.outputs.version }}
tag_name: v${{ needs.build.outputs.version }}
body: |
## Changes
${{ needs.build.outputs.last_tag_commit_hash }}...${{ needs.build.outputs.commit_hash }}
### SHA256 Checksums
```
${{ steps.sha256_amd.outputs.SHA256 }}
${{ steps.sha256_arm.outputs.SHA256 }}
```
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}