diff --git a/.github/template_gitref b/.github/template_gitref index eefaa803c..ab3a1dea1 100644 --- a/.github/template_gitref +++ b/.github/template_gitref @@ -1 +1 @@ -2021.08.26-282-g53132bb +2021.08.26-292-gc6f5178 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 88659df8a..9e6f3a85c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,11 +29,13 @@ jobs: - name: "Install python dependencies" run: | echo ::group::PYDEPS - pip install packaging wheel + pip install packaging twine wheel echo ::endgroup:: - name: "Build package" - run: "python3 setup.py sdist bdist_wheel --python-tag py3" - - name: 'Upload Package whl' + run: | + python3 setup.py sdist bdist_wheel --python-tag py3 + twine check dist/* + - name: "Upload Package whl" uses: "actions/upload-artifact@v3" with: name: "plugin_package" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81c1560e5..3da41760e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ defaults: working-directory: "pulp_deb" jobs: - ready-to-ship: + check-commits: runs-on: "ubuntu-latest" steps: - uses: "actions/checkout@v4" @@ -75,3 +75,19 @@ jobs: run: | cat deprecations-*.txt | sort -u ! cat deprecations-*.txt | grep '[^[:space:]]' + + ready-to-ship: + # This is a dummy dependent task to have a single entry for the branch protection rules. + runs-on: "ubuntu-latest" + needs: + - "check-commits" + - "lint" + - "test" + if: "always()" + steps: + - name: "Collect needed jobs results" + working-directory: "." + run: | + echo '${{toJson(needs)}}' | jq -r 'to_entries[]|select(.value.result!="success")|.key + ": " + .value.result' + echo '${{toJson(needs)}}' | jq -e 'to_entries|map(select(.value.result!="success"))|length == 0' + echo "CI says: Looks good!" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index ab512fa00..2d0c84641 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -88,7 +88,7 @@ jobs: - name: "Install python dependencies" run: | echo ::group::PYDEPS - pip install requests packaging~=21.3 mkdocs pymdown-extensions Jinja2<3.1 + pip install requests 'packaging~=21.3' mkdocs pymdown-extensions 'Jinja2<3.1' echo ::endgroup:: - name: "Set environment variables" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 05b868371..08bbc0511 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,7 +37,7 @@ jobs: - name: "Install python dependencies" run: | echo ::group::PYDEPS - pip install packaging~=21.3 bump2version gitpython towncrier wheel requests + pip install 'packaging~=21.3' bump2version gitpython towncrier wheel requests echo ::endgroup:: - name: "Configure Git with pulpbot name and email" @@ -51,29 +51,38 @@ jobs: env: SECRETS_CONTEXT: "${{ toJson(secrets) }}" - - name: Create the release commit, tag it, create a post-release commit, and build plugin package - run: python .github/workflows/scripts/release.py ${{ github.event.inputs.release }} + - name: "Create the release commit, tag it, create a post-release commit, and build plugin package" + run: | + python .github/workflows/scripts/release.py ${{ github.event.inputs.release }} + + - name: "Upload Package whl" + uses: "actions/upload-artifact@v3" + with: + name: "plugin_package" + path: "pulp_deb/dist/" + if-no-files-found: "error" - name: "Tar files" run: | tar -cvf pulp_deb.tar . - name: "Upload Artifact" - uses: actions/upload-artifact@v3 + uses: "actions/upload-artifact@v3" with: name: "pulp_deb.tar" path: "pulp_deb/pulp_deb.tar" build-bindings-docs: - needs: build-artifacts - runs-on: ubuntu-latest + needs: + - "build-artifacts" + runs-on: "ubuntu-latest" # Install scripts expect TEST to be set, 'docs' is most appropriate even though we don't run tests env: - TEST: docs + TEST: "docs" steps: - - uses: actions/download-artifact@v3 + - uses: "actions/download-artifact@v3" with: name: "pulp_deb.tar" path: "pulp_deb/" @@ -98,7 +107,7 @@ jobs: - name: "Install python dependencies" run: | echo ::group::PYDEPS - pip install towncrier twine wheel httpie docker netaddr boto3 ansible + pip install towncrier twine wheel httpie docker netaddr boto3 ansible mkdocs echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/pulp_deb/.ci/assets/httpie/" >> $GITHUB_ENV echo ::endgroup:: @@ -114,16 +123,15 @@ jobs: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}" - - name: Install + - name: "Install" run: | - export PLUGIN_VERSION=${{ github.event.inputs.release }} .github/workflows/scripts/install.sh + shell: "bash" env: PY_COLORS: "1" ANSIBLE_FORCE_COLOR: "1" GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}" - shell: bash - name: "Install Python client" run: | @@ -134,20 +142,20 @@ jobs: .github/workflows/scripts/install_ruby_client.sh shell: "bash" - name: "Upload python client packages" - uses: actions/upload-artifact@v3 + uses: "actions/upload-artifact@v3" with: name: "python-client.tar" path: "pulp_deb/deb-python-client.tar" if-no-files-found: "error" - name: "Upload python client docs" - uses: actions/upload-artifact@v3 + uses: "actions/upload-artifact@v3" with: name: "python-client-docs.tar" path: "pulp_deb/deb-python-client-docs.tar" if-no-files-found: "error" - name: "Upload ruby client packages" - uses: actions/upload-artifact@v3 + uses: "actions/upload-artifact@v3" with: name: "ruby-client.tar" path: "pulp_deb/deb-ruby-client.tar" @@ -178,71 +186,93 @@ jobs: docker exec pulp bash -c "pip3 list && pip3 install pipdeptree && pipdeptree" - publish: - runs-on: ubuntu-latest - needs: build-bindings-docs + publish-tag: + runs-on: "ubuntu-latest" + needs: + - "build-bindings-docs" env: - TEST: publish - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" steps: - - uses: actions/download-artifact@v3 + - uses: "actions/download-artifact@v3" with: name: "pulp_deb.tar" path: "pulp_deb/" - - uses: "actions/setup-python@v4" - with: - python-version: "3.8" - - - uses: ruby/setup-ruby@v1 - with: - ruby-version: "2.6" + - name: "Untar repository" + run: | + tar -xf pulp_deb.tar - name: "Configure Git with pulpbot name and email" run: | git config --global user.name 'pulpbot' git config --global user.email 'pulp-infra@redhat.com' - - name: Untar repository - run: | - tar -xf pulp_deb.tar - - name: "Setting secrets" run: | python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" env: SECRETS_CONTEXT: "${{ toJson(secrets) }}" + - name: "Push branch and tag to GitHub" + run: | + bash .github/workflows/scripts/push_branch_and_tag_to_github.sh ${{ github.event.inputs.release }} + publish-package: + runs-on: "ubuntu-latest" + needs: + - "build-bindings-docs" + - "publish-tag" + + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + steps: + - uses: "actions/checkout@v4" + with: + fetch-depth: 1 + path: "pulp_deb" + + - uses: "actions/download-artifact@v3" + with: + name: "plugin_package" + path: "pulp_deb/dist/" + + - uses: "actions/setup-python@v4" + with: + python-version: "3.8" + - name: "Install python dependencies" run: | echo ::group::PYDEPS - pip install twine gitpython requests packaging~=21.3 mkdocs pymdown-extensions Jinja2<3.1 + pip install twine echo ::endgroup:: - - name: Push branch and tag to GitHub - run: bash .github/workflows/scripts/push_branch_and_tag_to_github.sh ${{ github.event.inputs.release }} - - name: "Download built docs" - uses: actions/download-artifact@v3 - with: - name: "docs.tar" - path: "pulp_deb/" + - name: "Setting secrets" + run: | + python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" + env: + SECRETS_CONTEXT: "${{ toJson(secrets) }}" - - name: "Download Python client docs" - uses: actions/download-artifact@v3 + - name: "Deploy plugin to pypi" + run: | + .github/workflows/scripts/publish_plugin_pypi.sh ${{ github.event.inputs.release }} + publish-python-bindings: + runs-on: "ubuntu-latest" + needs: + - "build-bindings-docs" + - "publish-tag" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + steps: + - uses: "actions/checkout@v4" with: - name: "python-client-docs.tar" - path: "pulp_deb/" + fetch-depth: 1 + path: "pulp_deb" - - name: Publish docs to pulpproject.org - run: | - tar -xvf docs.tar - .github/workflows/scripts/publish_docs.sh tag ${{ github.event.inputs.release }} - - name: Deploy plugin to pypi - run: bash .github/workflows/scripts/publish_plugin_pypi.sh ${{ github.event.inputs.release }} - name: "Download Python client" - uses: actions/download-artifact@v3 + uses: "actions/download-artifact@v3" with: name: "python-client.tar" path: "pulp_deb/" @@ -251,11 +281,42 @@ jobs: run: | tar -xvf deb-python-client.tar + - uses: "actions/setup-python@v4" + with: + python-version: "3.8" + + - name: "Install python dependencies" + run: | + echo ::group::PYDEPS + pip install twine + echo ::endgroup:: + + - name: "Setting secrets" + run: | + python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" + env: + SECRETS_CONTEXT: "${{ toJson(secrets) }}" + - name: "Publish client to pypi" run: | - bash .github/workflows/scripts/publish_client_pypi.sh + bash .github/workflows/scripts/publish_client_pypi.sh ${{ github.event.inputs.release }} + publish-ruby-bindings: + runs-on: "ubuntu-latest" + needs: + - "build-bindings-docs" + - "publish-tag" + + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + steps: + - uses: "actions/checkout@v4" + with: + fetch-depth: 1 + path: "pulp_deb" + - name: "Download Ruby client" - uses: actions/download-artifact@v3 + uses: "actions/download-artifact@v3" with: name: "ruby-client.tar" path: "pulp_deb/" @@ -264,14 +325,82 @@ jobs: run: | tar -xvf deb-ruby-client.tar + - uses: ruby/setup-ruby@v1 + with: + ruby-version: "2.6" + + - name: "Setting secrets" + run: | + python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" + env: + SECRETS_CONTEXT: "${{ toJson(secrets) }}" + - name: "Publish client to rubygems" run: | - bash .github/workflows/scripts/publish_client_gem.sh + bash .github/workflows/scripts/publish_client_gem.sh ${{ github.event.inputs.release }} + publish-docs: + runs-on: "ubuntu-latest" + needs: + - "build-bindings-docs" + - "publish-tag" + + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + steps: + - uses: "actions/checkout@v4" + with: + fetch-depth: 1 + path: "pulp_deb" + + - uses: "actions/setup-python@v4" + with: + python-version: "3.8" + + - name: "Install python dependencies" + run: | + echo ::group::PYDEPS + pip install 'packaging~=21.3' requests + echo ::endgroup:: + + - name: "Setting secrets" + run: | + python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" + env: + SECRETS_CONTEXT: "${{ toJson(secrets) }}" - - name: Create release on GitHub - uses: actions/github-script@v7 + - name: "Download built docs" + uses: "actions/download-artifact@v3" + with: + name: "docs.tar" + path: "pulp_deb/" + + - name: "Download Python client docs" + uses: "actions/download-artifact@v3" + with: + name: "python-client-docs.tar" + path: "pulp_deb/" + + - name: "Publish docs to pulpproject.org" + run: | + tar -xvf docs.tar + .github/workflows/scripts/publish_docs.sh tag ${{ github.event.inputs.release }} + + create-gh-release: + runs-on: "ubuntu-latest" + needs: + - "build-bindings-docs" + - "publish-tag" + - "publish-package" + - "publish-python-bindings" + - "publish-ruby-bindings" + - "publish-docs" + + steps: + - name: "Create release on GitHub" + uses: "actions/github-script@v7" env: - TAG_NAME: ${{ inputs.release }} + TAG_NAME: "${{ inputs.release }}" with: script: | const { TAG_NAME } = process.env; diff --git a/.github/workflows/scripts/install_python_client.sh b/.github/workflows/scripts/install_python_client.sh index c04ba9ea6..219d260d4 100755 --- a/.github/workflows/scripts/install_python_client.sh +++ b/.github/workflows/scripts/install_python_client.sh @@ -26,8 +26,8 @@ rm -rf pulp_deb-client pushd pulp_deb-client python setup.py sdist bdist_wheel --python-tag py3 -twine check "dist/pulp_deb_client-$VERSION-py3-none-any.whl" || exit 1 -twine check "dist/pulp_deb-client-$VERSION.tar.gz" || exit 1 +twine check "dist/pulp_deb_client-$VERSION-py3-none-any.whl" +twine check "dist/pulp_deb-client-$VERSION.tar.gz" cmd_prefix pip3 install "/root/pulp-openapi-generator/pulp_deb-client/dist/pulp_deb_client-${VERSION}-py3-none-any.whl" tar cvf ../../pulp_deb/deb-python-client.tar ./dist @@ -37,6 +37,22 @@ find ./docs/* -exec sed -i 's/README//g' {} \; cp README.md docs/index.md sed -i 's/docs\///g' docs/index.md find ./docs/* -exec sed -i 's/\.md//g' {} \; -tar cvf ../../pulp_deb/deb-python-client-docs.tar ./docs + +cat >> mkdocs.yml << DOCSYAML +--- +site_name: PulpDeb Client +site_description: Deb bindings +site_author: Pulp Team +site_url: https://docs.pulpproject.org/pulp_deb_client/ +repo_name: pulp/pulp_deb +repo_url: https://github.com/pulp/pulp_deb +theme: readthedocs +DOCSYAML + +# Building the bindings docs +mkdocs build + +# Pack the built site. +tar cvf ../../pulp_deb/deb-python-client-docs.tar ./site popd popd diff --git a/.github/workflows/scripts/publish_client_gem.sh b/.github/workflows/scripts/publish_client_gem.sh index 898565556..9fc779a35 100755 --- a/.github/workflows/scripts/publish_client_gem.sh +++ b/.github/workflows/scripts/publish_client_gem.sh @@ -12,27 +12,24 @@ set -euv # make sure this script runs at the repo root cd "$(dirname "$(realpath -e "$0")")"/../../.. - -mkdir ~/.gem || true -touch ~/.gem/credentials -echo "--- -:rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials -sudo chmod 600 ~/.gem/credentials - -export VERSION=$(ls pulp_deb_client* | sed -rn 's/pulp_deb_client-(.*)\.gem/\1/p') +VERSION="$1" if [[ -z "$VERSION" ]]; then - echo "No client package found." - exit + echo "No version specified." + exit 1 fi -export response=$(curl --write-out %{http_code} --silent --output /dev/null https://rubygems.org/gems/pulp_deb_client/versions/$VERSION) +RESPONSE="$(curl --write-out '%{http_code}' --silent --output /dev/null "https://rubygems.org/gems/pulp_deb_client/versions/$VERSION")" -if [ "$response" == "200" ]; +if [ "$RESPONSE" == "200" ]; then echo "pulp_deb client $VERSION has already been released. Skipping." exit fi -GEM_FILE="$(ls pulp_deb_client-*)" -gem push ${GEM_FILE} +mkdir -p ~/.gem +touch ~/.gem/credentials +echo "--- +:rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials +sudo chmod 600 ~/.gem/credentials +gem push "pulp_deb_client-${VERSION}.gem" diff --git a/.github/workflows/scripts/publish_client_pypi.sh b/.github/workflows/scripts/publish_client_pypi.sh index 0a3f7ccd5..b6e6d57fe 100755 --- a/.github/workflows/scripts/publish_client_pypi.sh +++ b/.github/workflows/scripts/publish_client_pypi.sh @@ -12,11 +12,11 @@ set -euv # make sure this script runs at the repo root cd "$(dirname "$(realpath -e "$0")")/../../.." -VERSION="$(ls dist | sed -rn 's/pulp_deb-client-(.*)\.tar.gz/\1/p')" +VERSION="$1" if [[ -z "$VERSION" ]]; then - echo "No client package found." - exit + echo "No version specified." + exit 1 fi RESPONSE="$(curl --write-out '%{http_code}' --silent --output /dev/null "https://pypi.org/project/pulp-deb-client/$VERSION/")" diff --git a/.github/workflows/scripts/publish_docs.sh b/.github/workflows/scripts/publish_docs.sh index 36be1e9f2..67c2d0304 100755 --- a/.github/workflows/scripts/publish_docs.sh +++ b/.github/workflows/scripts/publish_docs.sh @@ -39,19 +39,6 @@ fi mkdir -p ../deb-bindings tar -xvf deb-python-client-docs.tar --directory ../deb-bindings pushd ../deb-bindings -cat >> mkdocs.yml << DOCSYAML ---- -site_name: PulpDeb Client -site_description: Deb bindings -site_author: Pulp Team -site_url: https://docs.pulpproject.org/pulp_deb_client/ -repo_name: pulp/pulp_deb -repo_url: https://github.com/pulp/pulp_deb -theme: readthedocs -DOCSYAML - -# Building the bindings docs -mkdocs build # publish to docs.pulpproject.org/pulp_deb_client rsync -avzh site/ doc_builder_pulp_deb@docs.pulpproject.org:/var/www/docs.pulpproject.org/pulp_deb_client/ diff --git a/.github/workflows/scripts/publish_plugin_pypi.sh b/.github/workflows/scripts/publish_plugin_pypi.sh index d0b76a259..00035c00f 100755 --- a/.github/workflows/scripts/publish_plugin_pypi.sh +++ b/.github/workflows/scripts/publish_plugin_pypi.sh @@ -7,21 +7,27 @@ # # For more info visit https://github.com/pulp/plugin_template +set -euv + # make sure this script runs at the repo root cd "$(dirname "$(realpath -e "$0")")"/../../.. -set -euv +VERSION="$1" -export response=$(curl --write-out %{http_code} --silent --output /dev/null https://pypi.org/project/pulp-deb/$1/) -if [ "$response" == "200" ]; +if [[ -z "$VERSION" ]]; then + echo "No version specified." + exit 1 +fi + +RESPONSE="$(curl --write-out '%{http_code}' --silent --output /dev/null "https://pypi.org/project/pulp-deb/$VERSION/")" + +if [ "$RESPONSE" == "200" ]; then - echo "pulp_deb $1 has already been released. Skipping." + echo "pulp_deb $VERSION has already been released. Skipping." exit fi -twine check dist/pulp_deb-$1-py3-none-any.whl || exit 1 -twine check dist/pulp-deb-$1.tar.gz || exit 1 -twine upload dist/pulp_deb-$1-py3-none-any.whl -u pulp -p $PYPI_PASSWORD -twine upload dist/pulp-deb-$1.tar.gz -u pulp -p $PYPI_PASSWORD - -exit $? +twine upload -u pulp -p "$PYPI_PASSWORD" \ +"dist/pulp_deb-$VERSION-py3-none-any.whl" \ +"dist/pulp-deb-$VERSION.tar.gz" \ +; diff --git a/.github/workflows/scripts/release.py b/.github/workflows/scripts/release.py index 1e4e6e11f..4e14a3b51 100755 --- a/.github/workflows/scripts/release.py +++ b/.github/workflows/scripts/release.py @@ -48,7 +48,7 @@ def create_release_commits(repo, release_version, plugin_path): issues = ",".join(issues_to_close) # First commit: changelog - os.system(f"towncrier --yes --version {release_version}") + os.system(f"towncrier build --yes --version {release_version}") git = repo.git git.add("CHANGES.rst") git.add("CHANGES/*") diff --git a/.github/workflows/scripts/script.sh b/.github/workflows/scripts/script.sh index 7b255faf4..74b24f12c 100755 --- a/.github/workflows/scripts/script.sh +++ b/.github/workflows/scripts/script.sh @@ -29,7 +29,7 @@ export PULP_URL="https://pulp" if [[ "$TEST" = "docs" ]]; then if [[ "$GITHUB_WORKFLOW" == "Deb CI" ]]; then - towncrier --yes --version 4.0.0.ci + towncrier build --yes --version 4.0.0.ci fi cd docs make PULP_URL="$PULP_URL" diagrams html diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 88f2ab0e2..9eb0ff80c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -51,7 +51,7 @@ jobs: - name: "Install python dependencies" run: | echo ::group::PYDEPS - pip install towncrier twine wheel httpie docker netaddr boto3 ansible + pip install towncrier twine wheel httpie docker netaddr boto3 ansible mkdocs echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/pulp_deb/.ci/assets/httpie/" >> $GITHUB_ENV echo ::endgroup:: diff --git a/.github/workflows/update_ci.yml b/.github/workflows/update_ci.yml index 8af03d033..75985bf0a 100644 --- a/.github/workflows/update_ci.yml +++ b/.github/workflows/update_ci.yml @@ -25,9 +25,10 @@ jobs: steps: - uses: "actions/checkout@v4" with: - fetch-depth: 1 + fetch-depth: 0 repository: "pulp/plugin_template" path: "plugin_template" + - uses: "actions/setup-python@v4" with: python-version: "3.8" diff --git a/CHANGES/.TEMPLATE.rst b/CHANGES/.TEMPLATE.rst index a5b57d696..49c2305d7 100644 --- a/CHANGES/.TEMPLATE.rst +++ b/CHANGES/.TEMPLATE.rst @@ -1,4 +1,12 @@ -{# TOWNCRIER TEMPLATE #} +{% if render_title %} +{% if versiondata.name %} +{{ versiondata.name }} {{ versiondata.version }} ({{ versiondata.date }}) +{{ top_underline * ((versiondata.name + versiondata.version + versiondata.date)|length + 4)}} +{% else %} +{{ versiondata.version }} ({{ versiondata.date }}) +{{ top_underline * ((versiondata.version + versiondata.date)|length + 3)}} +{% endif %} +{% endif %} {% for section, _ in sections.items() %} {% set underline = underlines[0] %}{% if section %}{{section}} {{ underline * section|length }}{% set underline = underlines[1] %} @@ -35,3 +43,5 @@ No significant changes. {% endfor %} ---- + +