-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (139 loc) · 4.16 KB
/
Copy pathrelease.yml
File metadata and controls
155 lines (139 loc) · 4.16 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
name: Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
tag:
description: Existing git tag to release (for example v0.1.0)
required: true
type: string
draft:
description: Create a draft release instead of publishing
required: false
type: boolean
default: true
permissions:
contents: write
concurrency:
group: release-${{ inputs.tag || github.ref }}
cancel-in-progress: false
jobs:
meta:
name: Check version
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.meta.outputs.tag }}
version: ${{ steps.meta.outputs.version }}
ref: ${{ steps.meta.outputs.ref }}
prerelease: ${{ steps.meta.outputs.prerelease }}
draft: ${{ steps.draft.outputs.draft }}
steps:
- name: Resolve tag
id: resolve
env:
EVENT_NAME: ${{ github.event_name }}
DISPATCH_TAG: ${{ inputs.tag }}
REF_NAME: ${{ github.ref_name }}
run: |
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
TAG="$DISPATCH_TAG"
else
TAG="$REF_NAME"
fi
TAG="${TAG#refs/tags/}"
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([.-].*)?$ ]]; then
echo "Tag must look like vX.Y.Z, got: $TAG"
exit 1
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v7
with:
ref: ${{ steps.resolve.outputs.tag }}
- uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Check package versions
id: meta
env:
TAG: ${{ steps.resolve.outputs.tag }}
run: python packaging/release_meta.py --tag "$TAG" --github-output
- name: Draft flag
id: draft
env:
EVENT_NAME: ${{ github.event_name }}
DRAFT_INPUT: ${{ inputs.draft }}
run: |
if [ "$EVENT_NAME" = "workflow_dispatch" ] && [ "$DRAFT_INPUT" = "true" ]; then
echo "draft=true" >> "$GITHUB_OUTPUT"
else
echo "draft=false" >> "$GITHUB_OUTPUT"
fi
desktop:
needs: meta
uses: ./.github/workflows/desktop.yml
with:
ref: ${{ needs.meta.outputs.ref }}
python:
name: Python package
needs: meta
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
ref: ${{ needs.meta.outputs.ref }}
- uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Build wheel and sdist
run: |
python -m pip install --upgrade pip build
python -m build
- uses: actions/upload-artifact@v7
with:
name: loadpath-python
if-no-files-found: error
path: dist/*
publish:
name: GitHub Release
needs: [meta, desktop, python]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v7
with:
path: artifacts
- name: Collect assets
run: |
mkdir -p release-assets
find artifacts -type f \( \
-name '*.AppImage' -o \
-name '*.deb' -o \
-name '*.dmg' -o \
-name '*.zip' -o \
-name '*.exe' -o \
-name '*.whl' -o \
-name '*.tar.gz' \
\) -exec cp -v {} release-assets/ \;
ls -la release-assets
test -n "$(ls -A release-assets)"
- name: Publish GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ needs.meta.outputs.tag }}
VERSION: ${{ needs.meta.outputs.version }}
DRAFT: ${{ needs.meta.outputs.draft }}
PRERELEASE: ${{ needs.meta.outputs.prerelease }}
run: |
ARGS=(--title "Loadpath ${VERSION}" --generate-notes --verify-tag)
if [ "$DRAFT" = "true" ]; then
ARGS+=(--draft)
fi
if [ "$PRERELEASE" = "true" ]; then
ARGS+=(--prerelease)
fi
if gh release view "$TAG" >/dev/null 2>&1; then
gh release upload "$TAG" release-assets/* --clobber
else
gh release create "$TAG" release-assets/* "${ARGS[@]}"
fi