Merge pull request #226 from cloudblue/lite-29138-clone-fail #138
Workflow file for this run
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: Publish Connect Command Line Client | |
on: | |
push: | |
tags: | |
- '*' | |
jobs: | |
linux: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
submodules: true | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry | |
poetry install | |
- name: Linting | |
run: | | |
poetry run flake8 | |
- name: Testing | |
run: | | |
poetry run pytest | |
- name: Checkout latest reports repository | |
run: | | |
poetry run python resources/get_latest_reports.py | |
- name: Extract tag name | |
uses: actions/github-script@v6 | |
id: tag | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
result-encoding: string | |
script: | | |
return context.payload.ref.replace(/refs\/tags\//, '') | |
- name: Build and publish to pypi.org | |
env: | |
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: | | |
poetry version ${{ steps.tag.outputs.result }} | |
poetry build | |
if [ "$(curl -s -o /dev/null -w '%{http_code}' https://pypi.org/pypi/connect-cli/${{ steps.tag.outputs.result }}/json)" = "404" ]; then poetry publish -u $TWINE_USERNAME -p $TWINE_PASSWORD; fi | |
- name: Set Connect and CLI major versions | |
id: cnctver | |
run: | | |
echo connect_major="$(curl -sI https://api.connect.cloudblue.com/public/v1|grep -Fi 'connect-version' | tr -d '\r' | sed -En 's/^Connect-Version: (.*)/\1/p'|cut -f1 -d'.')" >> $GITHUB_OUTPUT | |
echo cli_major="$(echo ${{ steps.tag.outputs.result }}|cut -f1 -d '.')" >> $GITHUB_OUTPUT | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: amd64,arm64 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: cloudblueconnect/connect-cli | |
tags: | | |
type=semver,pattern={{major}}.{{minor}},value=${{ steps.tag.outputs.result }}.0 | |
type=semver,pattern={{major}},value=${{ steps.tag.outputs.result }}.0 | |
type=raw,value=latest,enable=${{ steps.cnctver.outputs.connect_major == steps.cnctver.outputs.cli_major }} | |
flavor: | | |
latest=false | |
- name: Build and push docker image | |
id: docker_build | |
uses: docker/build-push-action@v3 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
context: . | |
file: resources/Dockerfile | |
tags: ${{ steps.meta.outputs.tags }} | |
- name: Docker image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} | |
windows: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
submodules: true | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry pynsist wheel | |
poetry install | |
- name: Checkout latest reports repository | |
run: | | |
poetry run python resources/get_latest_reports.py | |
- name: Extract tag name | |
uses: actions/github-script@v3 | |
id: tag | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
result-encoding: string | |
script: | | |
return context.payload.ref.replace(/refs\/tags\//, '') | |
- name: Generate connect-cli wheel | |
run: | | |
poetry version ${{ steps.tag.outputs.result }} | |
poetry build | |
cp dist/*.whl resources/. | |
- name: Generate pynsist config file | |
run: | | |
poetry export --format constraints.txt --without-hashes --output resources/requirements.txt | |
poetry run python resources/generate_pynsist_config.py | |
cat resources/ccli.cfg | |
- name: Build windows installer | |
run: | | |
pynsist resources/ccli.cfg | |
- name: Package windows distro | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
OS_NAME: windows | |
CPU_ARCH: amd64 | |
PKG_TAG: ${{ steps.tag.outputs.result }} | |
run: | | |
& { compress-archive -path '.\resources\build\nsis\connect-cli_${{ steps.tag.outputs.result }}_setup.exe' -destinationpath '.\connect-cli_${{ steps.tag.outputs.result }}_windows_amd64.zip' } | |
- name: Upload distro package to artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: windows_distro | |
path: connect-cli_${{ steps.tag.outputs.result }}_windows_amd64.zip | |
retention-days: 5 | |
release: | |
runs-on: ubuntu-latest | |
needs: [linux, windows] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
submodules: true | |
- name: Extract tag name | |
uses: actions/github-script@v6 | |
id: tag | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
result-encoding: string | |
script: | | |
return context.payload.ref.replace(/refs\/tags\//, '') | |
- name: Create release | |
uses: ncipollo/release-action@v1 | |
id: create_release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
allowUpdates: true | |
tag: ${{ steps.tag.outputs.result }} | |
name: Release ${{ steps.tag.outputs.result }} | |
draft: false | |
prerelease: false | |
- name: Download windows artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: windows_distro | |
path: ./ | |
- name: Attach windows distro to release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./connect-cli_${{ steps.tag.outputs.result }}_windows_amd64.zip | |
asset_name: connect-cli_${{ steps.tag.outputs.result }}_windows_amd64.zip | |
asset_content_type: application/zip |