Repository navigation
82 lines (71 loc) · 2.77 KB
/
Copy pathcd-syft-restrict.yml
File metadata and controls
82 lines (71 loc) · 2.77 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
name: CD - Syft Restrict
on:
workflow_dispatch:
inputs:
bump_type:
description: Version bump type
type: choice
default: patch
options:
- patch
- minor
- major
workflow_call:
inputs:
bump_type:
type: string
required: true
concurrency:
group: 'CD - Syft Restrict'
cancel-in-progress: false
jobs:
deploy-syft-restrict:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Configure git user
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# The branch already holds the version to release. The bump happens after
# the publish, so the version on the branch always names an unreleased
# version while people develop.
- name: Read the version to release
run: |
# Only this branch and no tags: a bare `git pull` fetches every old tag.
git pull --ff-only --no-tags origin "${{ github.ref_name }}"
VERSION=$(python -c "import tomllib; print(tomllib.load(open('packages/syft-restrict/pyproject.toml','rb'))['project']['version'])")
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Releasing syft-restrict $VERSION"
- name: Build package
working-directory: packages/syft-restrict
run: uv build --out-dir dist
- name: Publish to PyPI
working-directory: packages/syft-restrict
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASS_SYFT_RESTRICT }}
run: uvx twine upload --verbose dist/*
# The tag must name the published version, so it is created before the bump.
# The tag is annotated and pushed explicitly: `--follow-tags` only pushes
# annotated tags, so a lightweight tag would never reach origin. The bump
# and the tag are pushed together (--atomic), so a re-run never finds one
# without the other.
- name: Tag the release, then bump for the next one
run: |
git tag -a "syft-restrict/v${{ env.VERSION }}" -m "syft-restrict v${{ env.VERSION }}"
pip install packaging
OUTPUT=$(python scripts/bump_version.py syft-restrict ${{ inputs.bump_type }})
NEXT=$(echo "$OUTPUT" | sed -n '1p')
MODIFIED=$(echo "$OUTPUT" | sed -n '2p')
git add $MODIFIED
git commit -m "Bump syft-restrict to $NEXT for the next release"
git push --atomic origin HEAD "refs/tags/syft-restrict/v${{ env.VERSION }}"