Repository navigation
160 lines (127 loc) · 3.86 KB
/
Copy pathbuild.yml
File metadata and controls
160 lines (127 loc) · 3.86 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
name: Build and Release
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
name: linux
archive: pytextsearch-linux.tar.gz
- os: windows-latest
name: windows
archive: pytextsearch-windows.zip
- os: macos-latest
name: macos
archive: pytextsearch-macos.tar.gz
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install rich cryptography nuitka
- name: Build with Nuitka
run: |
python -m nuitka --standalone --follow-imports --assume-yes-for-downloads --output-dir=build textscan.py
# Create the package OUTSIDE the repository so copying the repository
# cannot recursively copy the package directory into itself.
- name: Create package directory
shell: bash
run: |
PACKAGE_DIR="$RUNNER_TEMP/pytextsearch-package"
rm -rf "$PACKAGE_DIR"
mkdir -p "$PACKAGE_DIR"
# Copy the entire repository.
# Only Git metadata and GitHub workflow files are excluded.
# Add the complete Nuitka standalone build.
cp -a build/textscan.dist/. "$PACKAGE_DIR/"
echo "PACKAGE_DIR=$PACKAGE_DIR" >> "$GITHUB_ENV"
- name: Package Linux
if: matrix.name == 'linux'
shell: bash
run: |
tar -czf "${{ matrix.archive }}" \
-C "$PACKAGE_DIR" .
- name: Package macOS
if: matrix.name == 'macos'
shell: bash
run: |
tar -czf "${{ matrix.archive }}" \
-C "$PACKAGE_DIR" .
- name: Package Windows
if: matrix.name == 'windows'
shell: pwsh
run: |
Compress-Archive `
-Path "$env:PACKAGE_DIR\*" `
-DestinationPath "${{ matrix.archive }}"
- name: Upload build
uses: actions/upload-artifact@v4
with:
name: pytextsearch-${{ matrix.name }}
path: ${{ matrix.archive }}
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download builds
uses: actions/download-artifact@v4
with:
path: release
merge-multiple: true
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: build-${{ github.sha }}
name: pytextsearch standalone
make_latest: true
generate_release_notes: false
files: release/*
cleanup-stale-tags:
needs: release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Remove stale build tags
env:
GH_TOKEN: ${{ github.token }}
run: |
set -e
echo "Getting tags associated with GitHub Releases..."
gh release list \
--limit 1000 \
--json tagName \
--jq '.[].tagName' > releases.txt
echo
echo "Released tags:"
cat releases.txt || true
echo
echo "Checking build-* tags..."
for tag in $(git tag -l 'build-*'); do
if grep -Fxq "$tag" releases.txt; then
echo "KEEP: $tag"
else
echo "DELETE: $tag"
git push origin --delete "$tag"
git tag -d "$tag"
fi
done
echo
echo "Stale tag cleanup complete."