-
Notifications
You must be signed in to change notification settings - Fork 1
148 lines (125 loc) · 3.79 KB
/
action.yml
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
name: pytest-coverage
on:
pull_request:
branches:
- '*'
permissions:
id-token: write
contents: read
attestations: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry flake8 pytest pytest-cov
poetry self add poetry-plugin-up
poetry self update
poetry install --no-root
poetry up
- name: Retrieve version
run: |
echo ::set-env name=APP_VERSION::$(poetry version -s)
- name: Pytest with coverage
run: |
coverage run -m pytest --nf
- name: Build coverage file
run: |
coverage report -m
- name: Build
run: |
poetry build
- name: Upload dist tar+gzip
uses: actions/upload-artifact@v4
with:
name: dist_gzip
path: ./dist/ssvc-${{ env.APP_VERSION }}.tar.gz
retention-days: 1
- name: Upload dist whl
uses: actions/upload-artifact@v4
with:
name: dist_whl
path: ./dist/ssvc-${{ env.APP_VERSION }}-py3-none-any.whl
retention-days: 1
- name: Coverage Badge
uses: tj-actions/coverage-badge-py@v2
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v19
id: verify-changed-files
with:
files: coverage.svg
release:
if: github.ref_type == 'tag'
needs: [ build ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download dist tar+gzip
uses: actions/download-artifact@v4
with:
name: dist_gzip
- name: Download dist whl
uses: actions/download-artifact@v4
with:
name: dist_whl
- name: Retrieve commit message
run: |
echo ::set-env name=COMMIT_MSG::$(git log -1 --pretty=format:"%s")
- name: Publish
run: |
poetry publish
- name: Tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git commit -a -s -m 'build(release): v${{ env.APP_VERSION }}'
git tag --force v${{ env.APP_VERSION }}
git push
git push --tags --force
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: ${{ env.COMMIT_MSG }}
draft: false
prerelease: false
- name: Upload Release Source
id: upload-release-source
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/ssvc-${{ env.APP_VERSION }}.tar.gz
asset_name: dist/ssvc-${{ env.APP_VERSION }}.tar.gz
asset_content_type: application/gzip
- name: Upload Release Wheel
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/ssvc-${{ env.APP_VERSION }}-py3-none-any.whl
asset_name: ssvc-${{ env.APP_VERSION }}-py3-none-any.whl
asset_content_type: application/octet-stream
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-path: ./dist/ssvc-${{ env.APP_VERSION }}-py3-none-any.whl
- name: Generate SBOM attestation
uses: actions/attest-sbom@v1
with:
subject-path: ./dist/ssvc-${{ env.APP_VERSION }}-py3-none-any.whl
sbom-path: ./sbom.spdx.json