forked from pyccel/pyccel
-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (131 loc) · 5.37 KB
/
Copy pathdeploy.yml
File metadata and controls
141 lines (131 loc) · 5.37 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
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
name: Deploy new version to PyPi
on:
workflow_run:
workflows: [Anaconda-Windows]
types:
- completed
jobs:
waitForWorklows:
name: Wait for workflows
runs-on: ubuntu-latest
if: github.event.workflow_run.head_branch == 'main' && github.repository == 'pyccel/pyccel'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install python dependencies
run: |
python -m pip install requests jwt
- name: Wait for workflows
run: |
python3 wait_for_main_workflows.py
working-directory: ./ci_tools
shell: bash
env:
COMMIT: ${{ github.event.workflow_run.head_sha }}
deployVersion:
runs-on: ubuntu-latest
needs: [waitForWorklows]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
ref: main
fetch-depth: 2
- name: Install dependencies
uses: ./.github/actions/linux_install
- name: Update build
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade build
python -m pip install --upgrade twine
- name: Build and deploy
if: github.repository == 'pyccel/pyccel'
run: |
echo ${{ github.event.workflow_run.head_branch }}
python3 -m build
ls dist/*
python3 -m twine upload --repository pypi dist/* --non-interactive
shell: bash
env:
TWINE_USERNAME: '__token__'
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
- name: Install Pyccel without tests
run: |
python -m pip install .
- name: "Get tag name"
id: tag_name
run: |
version=$(python -c "from pyccel import __version__; print(__version__)")
echo "VERSION=${version}" >> $GITHUB_OUTPUT
echo "TAG_NAME=v${version}" >> $GITHUB_OUTPUT
- name: "Get release notes"
id: release_notes
run: |
START_LINE=$(grep "^## " CHANGELOG.md -n | head -1 | cut -d: -f -1)
END_LINE=$(grep "^## " CHANGELOG.md -n | head -2 | tail -1 | cut -d: -f -1)
START_LINE=$((${START_LINE}+1))
END_LINE=$((${END_LINE}-1))
echo "## What's Changed" > release_notes.md
sed -n ${START_LINE},${END_LINE}p CHANGELOG.md >> release_notes.md
- name: "Get contributors"
run: |
# Get relevant commits
LAST_RELEASE_COMMIT=$(git log -2 --pretty=%H | tail -1)
CURRENT_RELEASE_COMMIT=$(git log -1 --pretty=%H)
# Find any new lines in the AUTHORS file
NEW_CONTRIBUTORS=$(git diff --no-indent-heuristic --unified=0 --no-color ${LAST_RELEASE_COMMIT}..${CURRENT_RELEASE_COMMIT} AUTHORS | { grep "^\+[^+]" || true; } | cut -d ' ' -f 2-)
if [ -n "${NEW_CONTRIBUTORS}" ]
then
# If there are new contributors then add a section with their names
echo "## New Contributors" >> release_notes.md
while IFS= read -r c
do
echo "- ${c}" >> release_notes.md
done <<< "${NEW_CONTRIBUTORS}"
echo "" >> release_notes.md
fi
# Find the PR which created the release
PR_ID=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /search/issues?q="${CURRENT_RELEASE_COMMIT}" | jq '.["items"][0]["number"]')
# Extract authors from all commits in the PR
CONTRIBUTORS=$(gh pr view ${PR_ID} --json commits | jq '.["commits"][]["authors"][]["login"]' | tr -d '"' | sort -u)
# Add a hidden section listing the user names of all authors on commits in this release
echo "<details>" >> release_notes.md
echo "" >> release_notes.md
echo "## Contributors" >> release_notes.md
for c in ${CONTRIBUTORS}
do
echo "- @$c" >> release_notes.md
done
echo "" >> release_notes.md
echo "</details>" >> release_notes.md
# Get the full changelog link
PREVIOUS_TAG=$(gh release list --limit 1 --json tagName | jq '.[]["tagName"]' | tr -d '"')
echo "" >> release_notes.md
echo "**Full list of changes**: [${PREVIOUS_TAG}..${tag_name}](https://github.com/pyccel/pyccel/compare/${PREVIOUS_TAG}..${tag_name})" >> release_notes.md
shell: bash
env:
GH_TOKEN: ${{ github.token }}
tag_name: ${{ steps.tag_name.outputs.TAG_NAME }}
- name: "Update repo tags"
uses: EndBug/latest-tag@latest
with:
ref: ${{ steps.tag_name.outputs.TAG_NAME }}
- name: "Update releases"
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/pyccel/pyccel/releases \
-f "tag_name=${tag_name}" -f "name=Version ${version}" -F "body=@release_notes.md" -F "draft=false" -F "prerelease=false" -F "generate_release_notes=false"
shell: bash
env:
tag_name: ${{ steps.tag_name.outputs.TAG_NAME }}
version: ${{ steps.tag_name.outputs.VERSION }}
release_notes: ${{ steps.release_notes.outputs.RELEASE_NOTES }}
GH_TOKEN: ${{ github.token }}