Skip to content

Commit cb40d56

Browse files
committed
Auto-publish workflow
1 parent 34b9824 commit cb40d56

File tree

2 files changed

+66
-3
lines changed

2 files changed

+66
-3
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ jobs:
2121

2222
- name: Prepare pin
2323
run: |
24-
git clone https://github.com/mosteo/yeison --branch devel
24+
git clone https://github.com/mosteo/yeison --branch main
2525
alr pin yeison_12 --use=yeison/yeison_12
2626
alr -C test/ pin yeison_12 --use=../yeison/yeison_12
27-
27+
2828
- name: Build library
2929
run: alr build
3030

3131
- name: Run tests
3232
run: alr -C test/ run
33-
33+

.github/workflows/publish.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: publish
2+
on:
3+
workflow_dispatch:
4+
5+
env:
6+
OWNER: mosteo
7+
INDEX: test-index
8+
TIMEOUT: 300
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: alire-project/setup-alire@v4
18+
19+
- name: Configure remote index (for the case of test runs)
20+
if: ${{env.INDEX}} != '' || ${{env.OWNER}} != ''
21+
run: |
22+
alr settings --set index.owner ${{env.OWNER}}
23+
alr settings --set index.repository_name ${{env.INDEX}}
24+
25+
- name: Publish
26+
shell: bash
27+
run: |
28+
alr publish --skip-build | tee publish.log
29+
30+
# Identify PR number from output
31+
# In python it would be: pr = re.search(r'/pull/(\d+) for details', p.out).group(1)
32+
33+
PR=$(grep -oP '/pull/\K\d+(?= for details)' publish.log)
34+
echo "PR created with number: $PR"
35+
36+
# Check periodically until the PR checks succeed or fail
37+
38+
waited = 0
39+
timeout = ${TIMEOUT:-300}
40+
while true; do
41+
sleep 10s
42+
waited=$((waited+10))
43+
line=$(alr publish --status | grep /$PR)
44+
if [[ $line == *Checks_Passed* ]]; then
45+
break
46+
elif [[ $line == *Checks_Failed* ]]; then
47+
echo "Checks failed unexpectedly for PR $PR: $line"
48+
echo Please review manually
49+
exit 1
50+
elif [[ $waited -gt $timeout ]]; then
51+
echo "Checks not completed after $timeout seconds for PR $PR"
52+
echo Please review manually
53+
exit 1
54+
else
55+
# Wait a bit and retry, but fail after so many time
56+
sleep 1
57+
waited=$((waited+1))
58+
fi
59+
done
60+
61+
# At this point the PR checks have passed and we can request a review
62+
63+
alr publish --request-review=$PR

0 commit comments

Comments
 (0)