-
Notifications
You must be signed in to change notification settings - Fork 11
138 lines (120 loc) · 4.29 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
128
129
130
131
132
133
134
135
136
137
138
name: Build and Create DMG
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev
jobs:
build:
runs-on: macos-latest
outputs:
version: ${{ env.VERSION }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install Dependencies
run: bun install
continue-on-error: false
- name: Install create-dmg
run: |
brew update
brew install create-dmg
continue-on-error: false
- name: Build and package app
run: bun run release
continue-on-error: false
- name: Get version from package.json
id: get_version
run: |
if [ -f "package.json" ]; then
echo "VERSION=$(jq -r .version package.json)" >> $GITHUB_ENV
else
echo "Error: package.json not found"
exit 1
fi
- name: Verify DMG files exist
run: |
for arch in x64 universal arm64; do
if [ ! -f "dist/AppleBlox-${VERSION}_${arch}.dmg" ]; then
echo "Error: DMG file for ${arch} not found"
exit 1
fi
done
- name: Upload (mac_x64)
uses: actions/upload-artifact@v4
with:
name: AppleBlox-${{ env.VERSION }}_x64.dmg
path: dist/AppleBlox-${{ env.VERSION }}_x64.dmg
if-no-files-found: error
retention-days: 30
- name: Upload (mac_universal)
uses: actions/upload-artifact@v4
with:
name: AppleBlox-${{ env.VERSION }}_universal.dmg
path: dist/AppleBlox-${{ env.VERSION }}_universal.dmg
if-no-files-found: error
retention-days: 30
- name: Upload (mac_arm64)
uses: actions/upload-artifact@v4
with:
name: AppleBlox-${{ env.VERSION }}_arm64.dmg
path: dist/AppleBlox-${{ env.VERSION }}_arm64.dmg
if-no-files-found: error
retention-days: 30
- name: Build Summary
if: always()
run: |
echo "### Build Results 📦" >> $GITHUB_STEP_SUMMARY
echo "Version: ${{ env.VERSION }}" >> $GITHUB_STEP_SUMMARY
echo "- x64 DMG: $(ls -lh dist/AppleBlox-${VERSION}_x64.dmg 2>/dev/null || echo 'Not built')" >> $GITHUB_STEP_SUMMARY
echo "- Universal DMG: $(ls -lh dist/AppleBlox-${VERSION}_universal.dmg 2>/dev/null || echo 'Not built')" >> $GITHUB_STEP_SUMMARY
echo "- ARM64 DMG: $(ls -lh dist/AppleBlox-${VERSION}_arm64.dmg 2>/dev/null || echo 'Not built')" >> $GITHUB_STEP_SUMMARY
create-release:
needs: build
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # This ensures we fetch all history and tags
- name: Get previous tag
run: |
echo "PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo '')" >> $GITHUB_ENV
- name: Generate commit history
run: |
if [ -n "${{ env.PREVIOUS_TAG }}" ]; then
echo "### Commits since ${{ env.PREVIOUS_TAG }}" > CHANGELOG.md
echo "" >> CHANGELOG.md
git log --pretty=format:"- [%h](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/%H) %s" ${{ env.PREVIOUS_TAG }}..HEAD >> CHANGELOG.md
else
echo "### Initial Release" > CHANGELOG.md
echo "" >> CHANGELOG.md
git log --pretty=format:"- [%h](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/%H) %s" >> CHANGELOG.md
fi
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: Release ${{ needs.build.outputs.version }}
tag_name: ${{ needs.build.outputs.version }}
draft: true
files: |
./artifacts/AppleBlox-*/*.dmg
generate_release_notes: true
body_path: CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}