-
Notifications
You must be signed in to change notification settings - Fork 208
134 lines (116 loc) · 4.67 KB
/
Copy pathrelease.yml
File metadata and controls
134 lines (116 loc) · 4.67 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
name: release
on:
schedule:
- cron: "0 0 * * 1" # Runs on main by default every Monday
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
get-release-info:
runs-on: ubuntu-24.04
if: github.repository == 'verus-lang/verus'
outputs:
release_tag: ${{ steps.get_release_info.outputs.release_tag }}
steps:
- name: Get Release Info
id: get_release_info
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
release_info=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/verus-lang/verus/releases/163437062)
echo "release_tag=$(echo $release_info | jq -cr '.tag_name')" >> "$GITHUB_OUTPUT"
build:
needs: [get-release-info]
uses: ./.github/workflows/build.yml
with:
checkout_ref: ${{ needs.get-release-info.outputs.release_tag }}
is_rolling: false
# The artifacts created by the `build` job already contain the new manifest information.
# The only responsibility of this job is to commit the new manifest file to the repo.
commit-toolchain-manifest:
needs: [get-release-info, build]
runs-on: ubuntu-24.04
steps:
- name: Checkout release source
uses: actions/checkout@v6
with:
ref: ${{ needs.get-release-info.outputs.release_tag }}
fetch-depth: 0
token: ${{ secrets.CRATES_UPDATE_TOKEN }}
- name: Setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.97.1
- name: Configure git
run: |
git config --global user.name 'Release Toolchain Manifest Bot'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
BRANCH="bot/release-toolchain-manifest-$(date +%Y%m%d)-${{ github.run_number }}"
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
git checkout -b "$BRANCH"
- name: Create toolchain manifest for the release
working-directory: ./source
run: |
cargo run -p cargo-verus-toolchains --bin create-manifest -- --write-to-dir cargo-verus/toolchain-manifests
- name: Commit toolchain manifest
run: |
git add source/cargo-verus/toolchain-manifests
if ! git diff --cached --quiet; then
git commit -m "Add stable toolchain manifest"
echo "CHANGED=true" >> $GITHUB_ENV
else
echo "No toolchain manifest was added"
fi
- name: Push branch and open PR
if: env.CHANGED == 'true'
env:
GH_TOKEN: ${{ secrets.CRATES_UPDATE_TOKEN }}
version: ${{ needs.build.outputs.version }}
PR_BODY: |-
Automated toolchain manifest update for the latest stable release.
CI run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
git push origin "$BRANCH"
gh pr create \
--title "Add toolchain manifest for Release ${version}" \
--body "$PR_BODY" \
--base main
gh pr merge --auto --merge
copy-release:
needs: [build]
runs-on: ubuntu-24.04
steps:
- name: download all artifacts
uses: actions/download-artifact@v8
- name: Create a New Release
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
version: ${{ needs.build.outputs.version }}
run: |
new_release_tag="release/${version}"
new_release_name="Release ${version}"
response=$(curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"tag_name\": \"$new_release_tag\", \"name\": \"$new_release_name\"}" \
https://api.github.com/repos/verus-lang/verus/releases)
echo $new_release_tag $new_release_name $response
new_release_id=$(echo $response | jq -r '.id')
echo "new_release_id=$new_release_id" >> $GITHUB_ENV
- name: Copy Assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
new_release_id: ${{ env.new_release_id }}
version: ${{ needs.build.outputs.version }}
run: |
assets=$(find verus-* -name '*.zip')
for asset in $assets; do
asset_name=$(basename $asset)
release_asset_name="verus-${version}-${asset_name#verus-}"
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @$asset \
"https://uploads.github.com/repos/verus-lang/verus/releases/$new_release_id/assets?name=$release_asset_name"
done