Release #46
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Release" | |
permissions: | |
contents: "write" | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- '*' | |
jobs: | |
get-tag: | |
name: "Get Tag From Package Version" | |
runs-on: "ubuntu-latest" | |
outputs: | |
pkg-version: ${{ steps.pkg-version.outputs.PKG_VERSION }} | |
steps: | |
- name: "Check out the repo" | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Get tag" | |
id: "pkg-version" | |
shell: "bash" | |
run: | | |
echo PKG_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/["]/, "", $2);gsub("\r", "", $2); printf("%s",$2) }' Cargo.toml) >> $GITHUB_OUTPUT | |
create-release: | |
name: "Create release" | |
needs: "get-tag" | |
runs-on: "ubuntu-latest" | |
steps: | |
- name: "Check out the repo" | |
uses: actions/checkout@v3 | |
- name: "Create release" | |
uses: "taiki-e/create-gh-release-action@v1" | |
with: | |
# (optional) Path to changelog. | |
# changelog: CHANGELOG.md | |
branch: "master" | |
ref: refs/tags/v${{ needs.get-tag.outputs.pkg-version }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
upload-assets: | |
name: "Upload assets to Github releases" | |
needs: | |
- "get-tag" | |
- "create-release" | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: "Check out the repo" | |
uses: actions/checkout@v3 | |
- name: "Upload Binaries" | |
uses: "taiki-e/upload-rust-binary-action@v1" | |
with: | |
bin: "sc2_controller,bot_controller,proxy_controller,k8s_controller" | |
archive: controllers-v${{ needs.get-tag.outputs.pkg-version }} | |
ref: refs/tags/v${{ needs.get-tag.outputs.pkg-version }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
push-to-registry: | |
name: "Push Docker image to Docker Hub" | |
needs: | |
- "get-tag" | |
runs-on: "ubuntu-latest" | |
steps: | |
- name: Check disk space | |
run: df . -h | |
- name: Free disk space | |
run: | | |
sudo docker rmi $(docker image ls -aq) >/dev/null 2>&1 || true | |
sudo rm -rf \ | |
/usr/share/dotnet /usr/local/lib/android /opt/ghc \ | |
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \ | |
/usr/lib/jvm || true | |
echo "some directories deleted" | |
sudo apt install aptitude -y >/dev/null 2>&1 | |
sudo aptitude purge aria2 ansible azure-cli shellcheck rpm xorriso zsync \ | |
esl-erlang firefox gfortran-8 gfortran-9 google-chrome-stable \ | |
google-cloud-sdk imagemagick \ | |
libmagickcore-dev libmagickwand-dev libmagic-dev ant ant-optional kubectl \ | |
mercurial apt-transport-https mono-complete libmysqlclient \ | |
unixodbc-dev yarn chrpath libssl-dev libxft-dev \ | |
libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev \ | |
snmp pollinate libpq-dev postgresql-client powershell ruby-full \ | |
sphinxsearch subversion mongodb-org azure-cli microsoft-edge-stable \ | |
-y -f >/dev/null 2>&1 | |
sudo aptitude purge google-cloud-sdk -f -y >/dev/null 2>&1 | |
sudo aptitude purge microsoft-edge-stable -f -y >/dev/null 2>&1 || true | |
sudo apt purge microsoft-edge-stable -f -y >/dev/null 2>&1 || true | |
sudo aptitude purge '~n ^mysql' -f -y >/dev/null 2>&1 | |
sudo aptitude purge '~n ^php' -f -y >/dev/null 2>&1 | |
sudo aptitude purge '~n ^dotnet' -f -y >/dev/null 2>&1 | |
sudo apt-get autoremove -y >/dev/null 2>&1 | |
sudo apt-get autoclean -y >/dev/null 2>&1 | |
echo "some packages purged" | |
- name: Check disk space | |
run: | | |
sudo dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -nr | head | |
df . -h | |
sudo du /usr/ -hx -d 4 --threshold=1G | sort -hr | head | |
- name: "Check out the repo" | |
uses: actions/checkout@v3 | |
- name: "Log in to Docker Hub" | |
uses: "docker/login-action@v2" | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: "Docker compose version" | |
run: docker compose version | |
- name: "Docker version" | |
run: docker --version | |
- name: "Build the docker-compose stack with version && push" | |
run: CARGO_FLAGS="--release" TAG=v${{ needs.get-tag.outputs.pkg-version }} docker compose -f docker/docker-compose.yml build --push | |
update-kustomize-tags-staging: | |
name: "Update Kustomize Image tags" | |
needs: | |
- "get-tag" | |
- "push-to-registry" | |
runs-on: "ubuntu-latest" | |
steps: | |
- name: "Check out the repo" | |
uses: actions/checkout@v3 | |
- name: Setup Kustomize | |
uses: imranismail/setup-kustomize@v1 | |
with: | |
kustomize-version: "3.6.1" | |
- name: Update Kubernetes resources | |
run: | | |
cd kubernetes/overlays/staging | |
kustomize edit set image aiarena/k8s-controller=:v${{ needs.get-tag.outputs.pkg-version }} | |
cat kustomization.yaml | |
- name: Commit files | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git commit -am "Bump staging docker tag" | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} |