build(deps): bump Microsoft.Extensions.Hosting #43
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: 'vault-appsettings-linter' | |
on: | |
push: | |
branches-ignore: | |
- '*' | |
release: | |
types: | |
- created | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
cd utils/linter | |
python3 -m pip install --upgrade pip | |
pip3 install --upgrade setuptools ruff pytest pytest-cov | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
- name: Run Python Linter | |
run: | | |
cd utils/linter | |
ruff --output-format=github --ignore=E501 src/ | |
- name: Change to linter directory and run tests | |
run: | | |
cd utils/linter | |
pytest --cov-report html --cov -v | |
- name: Archive code coverage results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: code-coverage-report | |
path: utils/linter/htmlcov/* | |
retention-days: 31 | |
release-pypi-package: | |
runs-on: ubuntu-latest | |
needs: test | |
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: Check Tag Pattern | |
run: | | |
if [[ "${{ github.ref }}" =~ refs/tags/[0-9]+\.[0-9]+\.[0-9]+ ]]; then | |
echo "Publishing PyPi package with tag '${{ github.ref }}'" | |
else | |
echo "Skipping job as the tag does not match the pattern X.Y.Z" | |
exit 1 | |
fi | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
cd utils/linter | |
python -m pip install --upgrade pip | |
pip install --upgrade build twine | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
- name: Build and upload to PyPI | |
env: | |
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: | | |
cd utils/linter | |
PYPI_PACKAGE_VERSION=$(echo "${{ github.ref }}" | sed 's/refs\/tags\///') | |
sed -i 's/version = "0.0.0"/version = "'$PYPI_PACKAGE_VERSION'"/' pyproject.toml | |
python -m build | |
twine upload dist/* | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: vault-appsettings-linter-package-dist | |
path: utils/linter/dist | |
release-docker-image: | |
runs-on: ubuntu-latest | |
needs: release-pypi-package | |
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: Check Tag Pattern | |
run: | | |
if [[ "${{ github.ref }}" =~ refs/tags/[0-9]+\.[0-9]+\.[0-9]+ ]]; then | |
echo "Publishing Docker image with tag '${{ github.ref }}'" | |
else | |
echo "Skipping job as the tag does not match the pattern X.Y.Z" | |
exit 1 | |
fi | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: vault-appsettings-linter-package-dist | |
path: utils/linter/dist | |
- name: Build and release Docker image | |
env: | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
run: | | |
cd utils/linter | |
echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin | |
DOCKER_IMAGE_TAG=$(echo "${{ github.ref }}" | sed 's/refs\/tags\///') | |
docker build \ | |
-t stratioautomotive/vault-appsettings-linter:$DOCKER_IMAGE_TAG \ | |
-t stratioautomotive/vault-appsettings-linter:latest \ | |
--build-arg "PYPI_PACKAGE_VERSION=$DOCKER_IMAGE_TAG" . | |
docker push stratioautomotive/vault-appsettings-linter:latest | |
docker push stratioautomotive/vault-appsettings-linter:$DOCKER_IMAGE_TAG |