-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (85 loc) · 3.38 KB
/
dry-run-release.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
name: Dry-run TestPyPI release on demand
on:
workflow_dispatch:
inputs:
version:
description: Dry-run release version identifier
required: true
permissions:
pull-requests: write
contents: write
jobs:
BuildTest:
name: "Dry run Release v${{ github.event.inputs.version }}"
if: ${{ github.repository_owner == 'XargsUK' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: 'main'
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies with Poetry
run: poetry install
- name: Bump version in pyproject.toml
run: poetry run python .github/scripts/update_version.py pyproject.toml ${{ github.event.inputs.version }}
- name: Lint with flake8
run: |
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
poetry run flake8 . --exit-zero --tee --output-file=flake8-report
- name: Test with pytest and coverage
run: |
poetry run coverage run -m pytest --junitxml=pytest-report.xml tests
poetry run coverage xml -o coverage-pytest.xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Commit & tag version bump in Git
uses: EndBug/add-and-commit@v9
with:
message: "Bump version to ${{ github.event.inputs.version }}-prerelease"
tag: "v${{ github.event.inputs.version }}-prerelease"
new_branch: "prerelease/v${{ github.event.inputs.version }}"
tag_push: '--force'
committer_name: GitHub Actions
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
- name: Build with Poetry
run: poetry build
- name: Publish package to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
verbose: true
PullRequest:
name: "Create v${{ github.event.inputs.version }} pull request"
if: ${{ github.repository_owner == 'XargsUK' }}
runs-on: ubuntu-latest
needs: BuildTest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: "main"
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v6
with:
branch: prerelease/v${{ github.event.inputs.version }}
commit-message: "Bump version to ${{ github.event.inputs.version }}"
title: "prerelease v${{ github.event.inputs.version }}"
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
body: "This PR includes changes for the new release `v${{ github.event.inputs.version }}`."
delete-branch: false
assignees: XargsUK
- name: Close pull request
uses: peter-evans/close-pull@v3
with:
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
comment: "Closed by release of v${{ github.event.inputs.version }}"
delete-branch: true