Skip to content

Fix scoring contest scoreboard #1

Fix scoring contest scoreboard

Fix scoring contest scoreboard #1

Workflow file for this run

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}