-
Notifications
You must be signed in to change notification settings - Fork 0
221 lines (192 loc) · 7.27 KB
/
submit-packages.yml
File metadata and controls
221 lines (192 loc) · 7.27 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
name: Submit to Package Managers
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'Version to submit (without v prefix)'
required: true
type: string
dry_run:
description: 'Dry run (generate manifests without submitting)'
required: false
type: boolean
default: false
package_managers:
description: 'Package managers to submit to (comma-separated, or "all")'
required: false
type: string
default: 'all'
jobs:
# Linux job for most package managers
submit-linux:
runs-on: ubuntu-latest
name: Submit (Linux)
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Setup AUR SSH key
if: env.AUR_SSH_KEY != ''
run: |
mkdir -p ~/.ssh
echo "$AUR_SSH_KEY" | base64 -d > ~/.ssh/aur
chmod 600 ~/.ssh/aur
ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts 2>/dev/null
cat >> ~/.ssh/config << EOF
Host aur.archlinux.org
IdentityFile ~/.ssh/aur
User aur
StrictHostKeyChecking no
EOF
chmod 600 ~/.ssh/config
env:
AUR_SSH_KEY: ${{ secrets.AUR_SSH_KEY }}
- name: Import GPG key
if: env.GPG_PRIVATE_KEY != ''
run: |
echo "$GPG_PRIVATE_KEY" | base64 -d | gpg --batch --import
# Trust the key
KEY_ID=$(gpg --list-keys --keyid-format LONG | grep -A1 "^pub" | tail -1 | awk '{print $1}')
echo "${KEY_ID}:6:" | gpg --import-ownertrust
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
- name: Determine version
id: version
run: |
if [ -n "${{ github.event.inputs.version }}" ]; then
VERSION="${{ github.event.inputs.version }}"
elif [ -n "${{ github.event.release.tag_name }}" ]; then
VERSION="${{ github.event.release.tag_name }}"
else
VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
fi
# Remove v prefix if present
VERSION="${VERSION#v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Submitting version: $VERSION"
- name: Determine package managers
id: pms
run: |
INPUT_PMS="${{ github.event.inputs.package_managers }}"
if [ -z "$INPUT_PMS" ]; then
INPUT_PMS="all"
fi
# If "all" or contains chocolatey, we need to exclude chocolatey from linux job
if [ "$INPUT_PMS" = "all" ]; then
# Run all except chocolatey on Linux
PMS="homebrew,scoop,winget,aur,apt,rpm,gentoo,nix"
else
# Remove chocolatey from the list for Linux job
PMS=$(echo "$INPUT_PMS" | sed 's/chocolatey,//g' | sed 's/,chocolatey//g' | sed 's/^chocolatey$//g')
fi
echo "package_managers=$PMS" >> $GITHUB_OUTPUT
- name: Submit to package managers
if: steps.pms.outputs.package_managers != ''
run: |
VERSION="${{ steps.version.outputs.version }}"
PMS="${{ steps.pms.outputs.package_managers }}"
DRY_RUN="${{ github.event.inputs.dry_run }}"
ARGS="-v $VERSION"
# Parse package managers
for PM in $(echo "$PMS" | tr ',' ' '); do
ARGS="$ARGS -p $PM"
done
# Add dry run flag if enabled
if [ "$DRY_RUN" = "true" ]; then
ARGS="$ARGS --dry-run"
fi
echo "Running: npx tsx scripts/submit-packages.ts $ARGS"
npx tsx scripts/submit-packages.ts $ARGS
env:
GITHUB_TOKEN: ${{ secrets.PKG_SUBMIT_TOKEN || secrets.GITHUB_TOKEN }}
AUR_SSH_KEY: ${{ secrets.AUR_SSH_KEY }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Summary
if: always()
run: |
echo "## Package Submission Summary (Linux)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Package Managers**: ${{ steps.pms.outputs.package_managers }}" >> $GITHUB_STEP_SUMMARY
echo "- **Dry Run**: ${{ github.event.inputs.dry_run || 'false' }}" >> $GITHUB_STEP_SUMMARY
# Windows job for Chocolatey
submit-chocolatey:
runs-on: windows-latest
name: Submit (Chocolatey)
if: >-
github.event.inputs.package_managers == 'all' ||
github.event.inputs.package_managers == '' ||
contains(github.event.inputs.package_managers, 'chocolatey')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Determine version
id: version
shell: bash
run: |
if [ -n "${{ github.event.inputs.version }}" ]; then
VERSION="${{ github.event.inputs.version }}"
elif [ -n "${{ github.event.release.tag_name }}" ]; then
VERSION="${{ github.event.release.tag_name }}"
else
VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
fi
# Remove v prefix if present
VERSION="${VERSION#v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Submitting version: $VERSION"
- name: Check Chocolatey API key
id: check-key
shell: bash
run: |
if [ -z "$CHOCOLATEY_API_KEY" ]; then
echo "has_key=false" >> $GITHUB_OUTPUT
echo "::warning::CHOCOLATEY_API_KEY secret not configured, skipping"
else
echo "has_key=true" >> $GITHUB_OUTPUT
fi
env:
CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }}
- name: Submit to Chocolatey
if: steps.check-key.outputs.has_key == 'true'
shell: bash
run: |
VERSION="${{ steps.version.outputs.version }}"
DRY_RUN="${{ github.event.inputs.dry_run }}"
ARGS="-v $VERSION -p chocolatey"
if [ "$DRY_RUN" = "true" ]; then
ARGS="$ARGS --dry-run"
fi
echo "Running: npx tsx scripts/submit-packages.ts $ARGS"
npx tsx scripts/submit-packages.ts $ARGS
env:
GITHUB_TOKEN: ${{ secrets.PKG_SUBMIT_TOKEN || secrets.GITHUB_TOKEN }}
CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }}
- name: Summary
if: always()
shell: bash
run: |
echo "## Package Submission Summary (Chocolatey)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Dry Run**: ${{ github.event.inputs.dry_run || 'false' }}" >> $GITHUB_STEP_SUMMARY