-
Notifications
You must be signed in to change notification settings - Fork 22
172 lines (153 loc) · 5.67 KB
/
Copy pathrelease.yml
File metadata and controls
172 lines (153 loc) · 5.67 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
169
170
171
172
name: Release
on:
push:
tags:
- 'v*.*.*'
jobs:
# ──────────────────────────────────────────
# 1. Build binaries for all platforms
# ──────────────────────────────────────────
build:
name: Build binary (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
asset_name: gitfetch-linux-x86_64
- os: macos-latest
asset_name: gitfetch-macos-arm64
- os: windows-latest
asset_name: gitfetch-windows-x86_64.exe
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
pip install -e .
- name: Build binary with PyInstaller
shell: bash
run: |
pyinstaller \
--onefile \
--name ${{ matrix.asset_name }} \
--distpath ./dist \
--paths src \
--hidden-import readchar \
--hidden-import webcolors \
--hidden-import requests \
--copy-metadata readchar \
--copy-metadata webcolors \
--copy-metadata requests \
run.py
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: ./dist/${{ matrix.asset_name }}*
# ──────────────────────────────────────────
# 2. Create GitHub Release and attach assets
# ──────────────────────────────────────────
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from tag
id: version
run: |
VERSION=${GITHUB_REF_NAME#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$GITHUB_REF_NAME" >> $GITHUB_OUTPUT
- name: Download all binary artifacts
uses: actions/download-artifact@v4
with:
path: ./dist
- name: Generate checksums
run: |
cd ./dist
find . -type f -exec shasum -a 256 {} \; > checksums.txt
cd ..
- name: Generate release notes
id: notes
run: |
if [ -f CHANGELOG.md ]; then
# Try [Unreleased] section first
awk '/^## \[Unreleased\]/{flag=1; next} /^## \[/{flag=0} flag' CHANGELOG.md \
| sed '/./,$!d' > release_body.md
# If empty, try the first versioned section (e.g. [1.4.0])
if [ ! -s release_body.md ]; then
awk '/^## \[[0-9]/{flag=1; next} /^## \[/{flag=0} flag' CHANGELOG.md \
| sed '/./,$!d' > release_body.md
fi
fi
if [ ! -s release_body.md ]; then
echo "No unreleased changelog entries found. Using default."
echo "## gitfetch v${{ steps.version.outputs.version }}" > release_body.md
echo "" >> release_body.md
echo "See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) for details." >> release_body.md
fi
echo "body<<EOF" >> $GITHUB_OUTPUT
cat release_body.md >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: v${{ steps.version.outputs.version }}
body: ${{ steps.notes.outputs.body }}
files: |
./dist/*/gitfetch-*
./dist/checksums.txt
fail_on_unmatched_files: false
# ──────────────────────────────────────────
# 3. Update Homebrew tap
# ──────────────────────────────────────────
update-homebrew:
name: Update Homebrew Tap
needs: release
runs-on: ubuntu-latest
if: ${{ vars.HOMEBREW_TAP_REPO != '' }}
steps:
- name: Checkout main repo
uses: actions/checkout@v4
with:
path: gitfetch
- name: Get version from tag
id: version
run: |
VERSION=${GITHUB_REF_NAME#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Checkout tap repo
uses: actions/checkout@v4
with:
repository: ${{ vars.HOMEBREW_TAP_REPO }}
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
path: homebrew-tap
- name: Update formula
run: |
cd homebrew-tap
chmod +x .github/scripts/update-homebrew.sh
VERSION=${{ steps.version.outputs.version }} ./.github/scripts/update-homebrew.sh
- name: Commit and push
run: |
cd homebrew-tap
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add Formula/gitfetch.rb
git commit -m "Update gitfetch to v${{ steps.version.outputs.version }}"
git push