Repository navigation
99 lines (90 loc) · 2.9 KB
/
Copy pathrelease.yml
File metadata and controls
99 lines (90 loc) · 2.9 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
name: Release
# Rolling releases: every merge to main that changes the package is tested, versioned from its
# commits, tagged, published to PyPI and announced as a GitHub release.
on:
push:
branches: [main]
workflow_dispatch:
inputs:
force:
description: "Release even if no package files changed"
type: boolean
default: false
permissions:
contents: read
concurrency:
group: release
cancel-in-progress: false
jobs:
ci:
uses: ./.github/workflows/ci.yml
version:
needs: ci
runs-on: ubuntu-latest
outputs:
version: ${{ steps.next.outputs.version }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- id: next
run: |
version=$(python3 scripts/next_version.py ${{ inputs.force && '--force' || '' }})
echo "version=$version" >> "$GITHUB_OUTPUT"
if [ -n "$version" ]; then echo "Next release: v$version"; else echo "No package changes; nothing to release."; fi
build:
needs: version
if: needs.version.outputs.version != ''
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
- name: Build
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ needs.version.outputs.version }}
run: uv build
- run: uvx twine check --strict dist/*
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: dist
path: dist/
publish:
needs: [version, build]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/opencode-python-sdk/${{ needs.version.outputs.version }}/
permissions:
id-token: write # trusted publishing, no stored token
attestations: write
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
with:
attestations: true
github-release:
needs: [version, publish]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dist
path: dist/
- name: Tag and create release
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.version.outputs.version }}
run: |
gh release create "v$VERSION" dist/* \
--repo "$GITHUB_REPOSITORY" \
--target "$GITHUB_SHA" \
--title "v$VERSION" \
--generate-notes