-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (144 loc) · 4.64 KB
/
Copy pathrelease.yml
File metadata and controls
167 lines (144 loc) · 4.64 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
name: Release
on:
push:
tags:
- "v*"
jobs:
build-packages:
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install build tools
run: pip install build twine
- name: Get version
id: version
run: |
VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Verify version matches tag
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v}
if [ "$TAG_VERSION" != "${{ steps.version.outputs.version }}" ]; then
echo "Tag version ($TAG_VERSION) does not match package version (${{ steps.version.outputs.version }})"
exit 1
fi
- name: Build package
run: python -m build
- name: Validate package
run: twine check dist/*
- name: Upload package artifacts
uses: actions/upload-artifact@v4
with:
name: python-packages
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
build-executables:
needs: build-packages
strategy:
matrix:
include:
- os: windows-latest
platform: windows
arch: x64
ext: .exe
- os: ubuntu-22.04
platform: linux
arch: x64
ext: ""
- os: macos-15-intel
platform: darwin
arch: x64
ext: ""
- os: macos-latest
platform: darwin
arch: arm64
ext: ""
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: pip install -e ".[dev]"
- name: Build executable
shell: bash
run: pyinstaller --onefile --name agent-mail --console src/agent_mail/__main__.py
- name: Rename executable
shell: bash
run: |
mv dist/agent-mail${{ matrix.ext }} dist/agent-mail-${{ needs.build-packages.outputs.version }}-${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.ext }}
- name: Make executable
if: matrix.platform != 'windows'
run: chmod +x dist/agent-mail-*
- name: Smoke test executable
shell: bash
run: ./dist/agent-mail-${{ needs.build-packages.outputs.version }}-${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.ext }} describe
- name: Upload executable artifact
uses: actions/upload-artifact@v4
with:
name: executable-${{ matrix.platform }}-${{ matrix.arch }}
path: dist/agent-mail-*
create-release:
runs-on: ubuntu-latest
needs: [build-packages, build-executables]
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Flatten artifacts
run: |
mkdir -p release-files
find artifacts -type f \( -name "*.whl" -o -name "*.tar.gz" -o -name "agent-mail-*" \) -exec cp {} release-files/ \;
ls -la release-files/
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: release-files/*
generate_release_notes: true
trigger-winget:
runs-on: ubuntu-latest
needs: [build-packages, create-release]
permissions:
actions: write
steps:
- name: Trigger WinGet publish workflow
uses: actions/github-script@v7
with:
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'winget-publish.yml',
ref: 'main',
inputs: { release_tag: '${{ github.ref_name }}' }
})
trigger-npm:
runs-on: ubuntu-latest
needs: [build-packages, create-release]
permissions:
actions: write
steps:
- name: Trigger npm publish workflow
uses: actions/github-script@v7
with:
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'npm-publish.yml',
ref: 'main',
inputs: { tag: '${{ github.ref_name }}' }
})