forked from icpctools/icpctools
-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (134 loc) · 5.21 KB
/
Copy pathci.yml
File metadata and controls
134 lines (134 loc) · 5.21 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: CI
on:
push:
branches:
- main
pull_request:
jobs:
build:
runs-on: ubuntu-latest
container: ghcr.io/icpctools/builder
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build
run: ant build
- name: Add run ID
run: echo $GITHUB_RUN_ID > dist/github_run_id.txt
- uses: actions/upload-artifact@v4.4.0
with:
name: build
path: dist/*
push-release:
runs-on: ubuntu-latest
container: ghcr.io/icpctools/website
needs: build
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4.1.8
with:
name: build
path: dist
- name: Create GitHub release
run: |
git config --global --add safe.directory ${GITHUB_WORKSPACE}
export VERSION_PREFIX=$(awk -F '=' '{ print $2 } ' version.properties)
VERSION=${VERSION_PREFIX}.$(git rev-list $GITHUB_SHA --count)
RELEASE_COMMIT=$(git rev-parse HEAD)
curl --silent --show-error --retry 6 --retry-all-errors --max-time 300 -X POST \
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases \
-d '{"tag_name":"'"v$VERSION"'", "name":"'"v$VERSION"'", "target_commitish":"'"$RELEASE_COMMIT"'","prerelease":true }' | \
tee ~/new-release.txt
RELEASE_ID=$(cat ~/new-release.txt | jq .id)
RELEASE_ASSET_UPLOAD_URL=https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets
cd dist
echo "Uploading release $VERSION"
for zip in *.zip
do
echo $zip...
curl --silent --show-error --retry 6 --retry-all-errors --max-time 300 --data-binary "@$zip" -X POST \
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
-H 'Accept: application/vnd.github.v3+json' \
-H 'Content-Type: application/zip' \
${RELEASE_ASSET_UPLOAD_URL}\?name=$zip \
| jq .state
echo $zip.sha256...
curl --silent --show-error --retry 6 --retry-all-errors --max-time 300 --data-binary "@$zip.sha256" -X POST \
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
-H 'Accept: application/vnd.github.v3+json' \
-H 'Content-Type: text/plain' \
${RELEASE_ASSET_UPLOAD_URL}\?name=$zip.sha256 \
| jq .state
echo $zip.sha512...
curl --silent --show-error --retry 6 --retry-all-errors --max-time 300 --data-binary "@$zip.sha512" -X POST \
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
-H 'Accept: application/vnd.github.v3+json' \
-H 'Content-Type: text/plain' \
${RELEASE_ASSET_UPLOAD_URL}\?name=$zip.sha512 \
| jq .state
done
update-website:
runs-on: ubuntu-latest
container: ghcr.io/icpctools/website
needs: push-release
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4.1.8
with:
name: build
path: dist
- name: Push release to website
run: |
eval $(ssh-agent -s)
echo "${{ secrets.SSH_PRIVATE_KEY_WEBSITE }}" | tr -d '\r' | ssh-add -
mkdir -p ~/.ssh
chmod 700 ~/.ssh
export GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=no'
git config --global user.email "bot@icpctools.org"
git config --global user.name "ICPC Tools bot"
website/scripts/populate-releases.py ${{ secrets.RELEASE_TOKEN }}
website/scripts/copy-readmes.py dist
cp doc/ChangeLog.md website/
sed -i 's/^# .*//' website/ChangeLog.md
sed -r 's/^## (.*)/#### \1/' -i website/ChangeLog.md
mkdir ~/website
git clone git@github.com:icpctools/icpctools.github.io.git ~/website
ln -s ~/website website/public
cd website
hugo
cd ~/website
git add .
git commit --allow-empty -m "Update website for icpctools commit $GITHUB_SHA"
git push
push-docker:
runs-on: ubuntu-latest
needs: push-release
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
run: |
export VERSION_PREFIX=$(awk -F '=' '{ print $2 } ' version.properties)
VERSION=${VERSION_PREFIX}.$(git rev-list $GITHUB_SHA --count)
cd build/cds/Docker
docker build -t ghcr.io/icpctools/cds:${VERSION} --build-arg CDS_VERSION=${VERSION} .
docker push ghcr.io/icpctools/cds:${VERSION}