Repository navigation
158 lines (141 loc) · 5.82 KB
/
Copy pathrelease.yml
File metadata and controls
158 lines (141 loc) · 5.82 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: read
actions: read
jobs:
# the macos and windows builds, the tests and the coverage are those of the CI run of main, the deb ones are built here
check:
name: Check the tag and the builds of main
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
build_run_id: ${{ steps.find_run.outputs.build_run_id }}
steps:
- name: Check the tag against the version in pyproject.toml
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
run: |
version=$(gh api -H "Accept: application/vnd.github.raw+json" \
"repos/${GITHUB_REPOSITORY}/contents/pyproject.toml?ref=${GITHUB_SHA}" \
| sed -n 's/^version = "\(.*\)"$/\1/p' | head -n1)
if [ -z "$version" ]; then
echo "::error::Could not read the version from pyproject.toml at ${GITHUB_SHA}."
exit 1
fi
if [ "v$version" != "$TAG" ]; then
echo "::error::The tag $TAG does not match the version $version in pyproject.toml. Bump the version before tagging."
exit 1
fi
# a successful run is one in which every build and every test passed
- name: Find the main-branch CI run for this commit
id: find_run
env:
GH_TOKEN: ${{ github.token }}
run: |
run_id=$(gh run list --repo "${{ github.repository }}" --workflow ci.yml \
--branch main --status success --limit 200 --json databaseId,headSha \
--jq ".[] | select(.headSha == \"${{ github.sha }}\") | .databaseId" | head -n1)
if [ -z "$run_id" ]; then
echo "::error::No successful CI run on main for commit ${{ github.sha }}. Push to main and wait for it to build and pass before tagging."
exit 1
fi
echo "build_run_id=${run_id}" >> "$GITHUB_OUTPUT"
# every release and architecture, built again for the tag
deb:
name: Build debian packages
needs: check
uses: ./.github/workflows/build-deb.yml
permissions:
contents: read
actions: write # build-deb.yml replaces its ccache entries
release:
name: Publish draft release
needs: [check, deb]
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write
actions: read
attestations: write
id-token: write
steps:
# the archive that GitHub attaches to a release is a git archive of the tag, with none of the submodules
# that the build needs
- name: Checkout repository with its submodules
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: source
submodules: recursive
persist-credentials: false
# the same tree gives the same bytes: sorted, with the time of the commit and no owner or name of the file in the gzip header
- name: Pack the source with its submodules
working-directory: source
env:
TAG: ${{ github.ref_name }}
run: |
prefix="monero-python-${TAG#v}"
mkdir -p ../release-assets
git ls-files --recurse-submodules -z \
| tar --null -T - --sort=name --mtime="@$(git log -1 --format=%ct)" --owner=0 --group=0 --numeric-owner \
--transform "flags=rSH;s,^,${prefix}/," -cf - \
| gzip -n > "../release-assets/${prefix}.tar.gz"
- name: Download deb packages
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: python3-monero_*
path: release-assets
merge-multiple: true
- name: Download macos wheels
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
github-token: ${{ github.token }}
run-id: ${{ needs.check.outputs.build_run_id }}
pattern: wheel-mac-*
path: release-assets
merge-multiple: true
- name: Download windows wheel
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
github-token: ${{ github.token }}
run-id: ${{ needs.check.outputs.build_run_id }}
name: wheel-windows-x86_64
path: release-assets
merge-multiple: true
- name: Download coverage report
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
github-token: ${{ github.token }}
run-id: ${{ needs.check.outputs.build_run_id }}
name: coverage-reports-linux
path: coverage-report
- name: Zip coverage HTML report
working-directory: coverage-report
run: |
mkdir -p ../release-assets
zip -r ../release-assets/coverage_monero_cpp_html.zip coverage_monero_cpp_html
# to check a download against what the workflow published: sha256sum -c SHA256SUMS
- name: Checksum the assets
working-directory: release-assets
run: sha256sum -- *.deb *.whl *.zip *.tar.gz > SHA256SUMS
# lets anyone check an asset against this workflow: gh attestation verify <asset> --repo libmonero/monero-python
- name: Attest the assets
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-path: release-assets/*
- name: Create draft release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
run: |
gh release create "$TAG" \
--repo "$GITHUB_REPOSITORY" \
--draft \
--title "$TAG" \
--notes-file source/.github/release-notes.md \
--generate-notes \
release-assets/*.deb release-assets/*.whl release-assets/*.zip release-assets/*.tar.gz release-assets/SHA256SUMS