Skip to content

Create release

Create release #290

Workflow file for this run

name: Create release
on:
registry_package:
types: [published, updated]
workflow_dispatch:
inputs:
new_bot_version:
description: 'Lynx_BOT release version'
required: true
default: ''
env:
LYNX_RELEASE_TAG: ${{ github.event.registry_package.package_version.container_metadata.tag.name }}
jobs:
create-release-bundle:
name: Create release bundle
if: github.event.inputs.new_bot_version != '' || (github.event.registry_package.name == 'lynx-bot' && github.event.registry_package.package_version.container_metadata.manifest.media_type == 'application/vnd.docker.distribution.manifest.list.v2+json')
runs-on: ubuntu-latest
steps:
- name: Install hub tool
run: |
sudo apt-get update && sudo apt-get install -y hub
- uses: actions/checkout@v2
- name: Set LYNX_RELEASE_TAG env var
if: env.LYNX_RELEASE_TAG == ''
shell: pwsh
run: |
echo "LYNX_RELEASE_TAG=${{ github.event.inputs.new_bot_version }}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- name: Replacing :latest with :${{ env.LYNX_RELEASE_TAG }} in docker-compose.yml
shell: pwsh
run: |
((Get-Content -path ./docker-compose.yml -Raw) -replace 'ghcr.io/lynx-chess/lynx-bot:latest','ghcr.io/lynx-chess/lynx-bot:${{ env.LYNX_RELEASE_TAG }}') | Set-Content -Path ./docker-compose.yml
- name: Upload Lynx_BOT v${{ env.LYNX_RELEASE_TAG }} artifact
uses: actions/upload-artifact@v2
with:
name: Lynx_BOT-${{ env.LYNX_RELEASE_TAG }}
path: |
docker-compose.yml
lynx_bot-config.yml
if-no-files-found: error
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: Lynx_BOT-${{ env.LYNX_RELEASE_TAG }}
path: artifacts/
- name: Compress artifact files
run: zip -0 -r -q -j "artifacts/Lynx_BOT-${{ env.LYNX_RELEASE_TAG }}.zip" "artifacts/"
- name: Create GitHub release and upload assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x
assets=()
for asset in artifacts/*.zip; do
assets+=("-a" "$asset")
done
tag_name="v${{ env.LYNX_RELEASE_TAG }}"
hub release create "${assets[@]}" --draft --message "$tag_name" --message "[Lynx $tag_name](https://github.com/lynx-chess/Lynx/releases/tag/$tag_name)" "$tag_name"