-
Notifications
You must be signed in to change notification settings - Fork 155
91 lines (79 loc) · 2.44 KB
/
cd.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
name: cd
on:
push:
tags:
# Stable releases (1.2.3)
- 'v?[0-9]+.[0-9]+.[0-9]+'
# Beta releases (1.2.3b0)
- 'v?[0-9]+.[0-9]+.[0-9]+b[0-9]+'
jobs:
ci:
uses: ./.github/workflows/ci.yml
build:
needs: [ci]
uses: ./.github/workflows/reusable-build.yml
# TODO: Test generated artifacts before releasing and publish
release:
needs: [ci, build]
runs-on: ubuntu-24.04
environment: production
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Get version from tag
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Tag version: $VERSION"
- name: Generate release notes
id: release_notes
run: |
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^)
NOTES=$(git log ${PREV_TAG}..HEAD --pretty=format:"* %s (%h)")
echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT
echo "## What's Changed" >> $GITHUB_OUTPUT
echo "$NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Rename executables
run: |
mv safety-linux/safety safety-linux/safety-linux
mv safety-macos/safety safety-macos/safety-macos
- name: Create GitHub Release
id: create_release
uses: softprops/[email protected]
with:
name: Version ${{ steps.get_version.outputs.version }}
body: ${{ steps.release_notes.outputs.RELEASE_NOTES }}
files: |
safety-linux/safety-linux
safety-windows/safety.exe
safety-macos/safety-macos
dist/*
prerelease: ${{ contains(steps.get_version.outputs.version, 'b') }}
token: ${{ secrets.SAFETY_BOT_TOKEN }}
publish:
needs: [release]
runs-on: ubuntu-24.04
environment:
name: pypi
url: https://pypi.org/p/safety
permissions:
id-token: write
steps:
- name: Download dist artifact
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
verbose: true
print-hash: true