diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 0000000..c1a43d9 --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,28 @@ +--- +name: Publish library to pypi + +on: + workflow_dispatch: + release: + types: + - published + +jobs: + deploy: + runs-on: ubuntu-latest + # Specifying a GitHub environment is optional, but strongly encouraged + environment: release + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + steps: + - uses: actions/checkout@v3 + + - name: Install poetry + run: pip install poetry + + - name: Build dist + run: poetry build + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4870330 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,87 @@ +--- +name: New release + +on: # yamllint disable-line rule:truthy + workflow_dispatch: + push: + branches: + - main + +jobs: + generate_changelog: + name: create release draft + if: github.repository == 'telekom-mms/aar_doc' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: main + + - name: 'Get Previous tag' + id: previoustag + uses: "WyriHaximus/github-action-get-previous-tag@master" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + - name: calculate next version + id: version + uses: patrickjahns/version-drafter-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install poetry + run: pip install poetry + + - name: Update Version with poetry + run: poetry version ${{ steps.version.outputs.next-version }} + + - name: Generate changelog + uses: charmixer/auto-changelog-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + future_release: ${{ steps.version.outputs.next-version }} + + - name: push new version + uses: github-actions-x/commit@v2.9 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + push-branch: 'main' + commit-message: 'update changelog' + force-add: 'true' + files: pyproject.toml CHANGELOG.md + name: Telekom MMS GmbH + email: mms@telekom.de + rebase: true + + - name: Generate changelog for the release + run: | + sed '/## \[${{ steps.previoustag.outputs.tag }}\]/Q' CHANGELOG.md > CHANGELOGRELEASE.md + + - name: Read CHANGELOG.md + id: package + uses: juliangruber/read-file-action@v1 + with: + path: ./CHANGELOGRELEASE.md + + - name: Delete old drafts + uses: hugo19941994/delete-draft-releases@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create Release draft + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + release_name: ${{ steps.version.outputs.next-version }} + tag_name: ${{ steps.version.outputs.next-version }} + body: | + ${{ steps.package.outputs.content }} + draft: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..d6cd4d0 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,40 @@ +--- +name: tests + +on: + workflow_dispatch: + push: + branches: [main] + pull_request: + branches: [main] + schedule: + - cron: '0 6 * * 0' + +jobs: + tests: + name: Run tests (py${{ matrix.python }}) + runs-on: ubuntu-latest + strategy: + matrix: + python: + - "3.8" + - "3.9" + - "3.10" + - "3.11" + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + + - name: Install poetry + run: pip install poetry + + - name: Install dependencies + run: poetry install + + - name: Run tests + run: poetry run python -m pytest -v tests/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 998bdc2..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,37 +0,0 @@ -image: python:3.9 - -stages: - - lint - - test - -before_script: - - pip install poetry - - poetry config virtualenvs.create false - - poetry install - -black: - stage: lint - script: - - poetry run black --diff --check . - -mypy: - stage: lint - script: - - poetry run mypy . - -isort: - stage: lint - script: - - poetry run isort --diff --check . - -pytest: - stage: test - script: - - poetry run pytest -v --cov=ansible_role_docs - - poetry run coverage xml - coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/' - artifacts: - reports: - coverage_report: - coverage_format: cobertura - path: coverage.xml