-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (79 loc) · 2.66 KB
/
release.yml
File metadata and controls
95 lines (79 loc) · 2.66 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
name: Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
permissions:
contents: write
id-token: write
packages: write
attestations: write
jobs:
release:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v5
with:
version: "0.6.9"
- name: Set version
run: |
if [ "${{ github.event_name }}" = "push" ]; then
echo "VERSION=${GITHUB_REF_NAME}" >> "$GITHUB_ENV"
else
echo "VERSION=workflow-${GITHUB_RUN_ID}" >> "$GITHUB_ENV"
fi
- name: Build wheel and sdist
run: uv build
- name: Attest distribution artifacts
if: github.event_name == 'push'
uses: actions/attest-build-provenance@v2
with:
subject-path: |
dist/*.whl
dist/*.tar.gz
- name: Test wheel installation
run: |
python -m venv /tmp/nc-venv
/tmp/nc-venv/bin/pip install --upgrade pip
/tmp/nc-venv/bin/pip install dist/*.whl
/tmp/nc-venv/bin/python -m noisecutter --help
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
run: |
docker build -t "ghcr.io/${{ github.repository }}/noisecutter:${{ env.VERSION }}" .
docker build -t "ghcr.io/${{ github.repository }}/noisecutter:latest" .
- name: Test Docker image
run: docker run --rm "ghcr.io/${{ github.repository }}/noisecutter:${{ env.VERSION }}" --help
- name: Log in to GHCR
if: github.event_name == 'push'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Docker image
if: github.event_name == 'push'
run: |
docker push "ghcr.io/${{ github.repository }}/noisecutter:${{ env.VERSION }}"
docker push "ghcr.io/${{ github.repository }}/noisecutter:latest"
- name: Publish to PyPI
if: github.event_name == 'push'
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
skip-existing: true
- name: Create GitHub Release
if: github.event_name == 'push'
uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true
draft: false
prerelease: ${{ contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc') }}