Fix CI #279
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: Build and Publish | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- '*' | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Fetch tags | |
run: git fetch --tags --force | |
- name: Metadata | |
run: echo "IS_RELEASE=${{ startsWith(github.ref, 'refs/tags/') }}" >> $GITHUB_ENV | |
- name: Environment | |
run: | | |
echo "VERSION=$(python build/print_version.py ${{ github.run_number }} ${{ env.IS_RELEASE }} false)" >> $GITHUB_ENV | |
echo "PYPI_VERSION=$(python build/print_version.py ${{ github.run_number }} ${{ env.IS_RELEASE }} pypi)" >> $GITHUB_ENV | |
echo "$(python build/print_solution.py)" >> $GITHUB_ENV | |
- name: Extract annotation tag | |
if: ${{ env.IS_RELEASE == 'true' }} | |
run: python build/create_tag_body.py | |
- name: Set up dotnet | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: "9.0.x" | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.10" | |
- name: Create Docker Output Folder | |
run: mkdir --parent artifacts/images | |
- name: Install | |
run: | | |
npm install -g pyright | |
python -m pip install -r requirements.txt | |
- name: Docker Setup | |
id: buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Build | |
run: | | |
dotnet publish -c Release -o app /p:GeneratePackage=true src/agent/dotnet/agent.csproj | |
python -m build --wheel --outdir artifacts/package --no-isolation src/remoting/python | |
- name: Test | |
run: | | |
dotnet test -c Release | |
pyright | |
pytest | |
- name: Docker Build | |
run: | | |
docker build -t nexus-main/nexus-agent-dotnet:v_next -f src/agent/dotnet/Dockerfile . | |
docker save --output artifacts/images/nexus_agent_dotnet_image.tar nexus-main/nexus-agent-dotnet:v_next | |
docker build -t nexus-main/nexus-agent-python:v_next -f src/agent/python/Dockerfile . | |
docker save --output artifacts/images/nexus_agent_python_image.tar nexus-main/nexus-agent-python:v_next | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts | |
path: | | |
artifacts/*.txt | |
artifacts/package/ | |
artifacts/images/ | |
outputs: | |
is_release: ${{ env.IS_RELEASE }} | |
version: ${{ env.VERSION }} | |
publish_dev: | |
needs: build | |
name: Publish (dev) | |
runs-on: ubuntu-latest | |
if: ${{ needs.build.outputs.is_release != 'true' }} | |
steps: | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: artifacts | |
path: artifacts | |
- name: Docker Load Image | |
run: | | |
docker load --input artifacts/images/nexus_agent_dotnet_image.tar | |
docker load --input artifacts/images/nexus_agent_python_image.tar | |
- name: Nuget package (MyGet) | |
run: dotnet nuget push 'artifacts/package/release/*.nupkg' --api-key ${MYGET_API_KEY} --source https://www.myget.org/F/apollo3zehn-dev/api/v3/index.json | |
env: | |
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }} | |
- name: Python package (MyGet) | |
run: 'for filePath in artifacts/package/*.whl; do curl -k -X POST https://www.myget.org/F/apollo3zehn-dev/python/upload -H "Authorization: Bearer ${MYGET_API_KEY}" -F "data=@$filePath"; done' | |
env: | |
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }} | |
- name: Docker Login (Github Container Registry) | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker Push | |
run: | | |
docker tag nexus-main/nexus-agent-dotnet:v_next ghcr.io/nexus-main/nexus-agent-dotnet:${{ needs.build.outputs.version }} | |
docker push ghcr.io/nexus-main/nexus-agent-dotnet:${{ needs.build.outputs.version }} | |
docker tag nexus-main/nexus-agent-python:v_next ghcr.io/nexus-main/nexus-agent-python:${{ needs.build.outputs.version }} | |
docker push ghcr.io/nexus-main/nexus-agent-python:${{ needs.build.outputs.version }} | |
publish_release: | |
needs: build | |
name: Publish (release) | |
runs-on: ubuntu-latest | |
if: ${{ needs.build.outputs.is_release == 'true' }} | |
steps: | |
- name: Install | |
run: | | |
python -m pip install twine | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: artifacts | |
path: artifacts | |
- name: Docker Load Image | |
run: | | |
docker load --input artifacts/images/nexus_agent_dotnet_image.tar | |
docker load --input artifacts/images/nexus_agent_python_image.tar | |
- name: GitHub Release Artifacts | |
uses: softprops/action-gh-release@v1 | |
with: | |
body_path: artifacts/tag_body.txt | |
- name: Nuget package (Nuget) | |
run: dotnet nuget push 'artifacts/package/release/*.nupkg' --api-key ${NUGET_API_KEY} --source https://api.nuget.org/v3/index.json | |
env: | |
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
- name: Python Package (PyPI) | |
run: twine upload artifacts/package/*.whl -u__token__ -p"${PYPI_API_KEY}" | |
env: | |
PYPI_API_KEY: ${{ secrets.PYPI_API_KEY }} | |
- name: Docker Login (Docker Hub) | |
uses: docker/login-action@v1 | |
with: | |
username: nexusmain | |
password: ${{ secrets.DOCKER_API_KEY }} | |
- name: Docker Push | |
run: | | |
docker tag nexus-main/nexus-agent-dotnet:v_next nexusmain/nexus-agent-dotnet:${{ needs.build.outputs.version }} | |
docker push nexusmain/nexus-agent-dotnet:${{ needs.build.outputs.version }} | |
docker tag nexus-main/nexus-agent-python:v_next nexusmain/nexus-agent-python:${{ needs.build.outputs.version }} | |
docker push nexusmain/nexus-agent-python:${{ needs.build.outputs.version }} |