Skip to content

ci: bump action-gh-release from v1 to v2 (actionlint flagged v1 too old) #14

ci: bump action-gh-release from v1 to v2 (actionlint flagged v1 too old)

ci: bump action-gh-release from v1 to v2 (actionlint flagged v1 too old) #14

Workflow file for this run

name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
schedule:
- cron: '0 0 * * *' # Daily at midnight
permissions:
contents: read
packages: write
issues: write
pull-requests: write
env:
PYTHON_VERSION: "3.x"
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Lint with Ruff
run: ruff check .
- name: Check formatting with Ruff
run: ruff format --check .
- name: Run tests
run: pytest -v --cov=replace_text --cov-report=term-missing
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}
path: htmlcov/
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Run Bandit (Python security)
run: |
python -m pip install --upgrade pip bandit
bandit -r replace_text -ll
- name: Run gitleaks (secret scanning)
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run actionlint (workflow lint)
run: |
bash <(curl -sSf https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
./actionlint -color
integration:
runs-on: ubuntu-latest
needs: [test, security]
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run integration tests
run: |
# Test config generation
python -m replace_text.replace_text --generate-config test_dict '{"key1": "value1", "key2": "value2"}' --output test_config.json
cat test_config.json
rm test_config.json
# Test with multiple dictionaries
cat > test_multi.json << 'EOF'
{
"version": "1.0",
"dictionaries": {
"dict1": {"foo": "bar"},
"dict2": {"hello": "world"}
},
"ignore_extensions": [],
"ignore_directories": [],
"ignore_file_prefixes": []
}
EOF
python -m replace_text.replace_text --config test_multi.json --direction 1 --folder . --dict-name dict1
rm test_multi.json
- name: Cleanup
if: always()
run: |
rm -f test_config.json
rm -f test_multi.json
deploy:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
needs: [test, security, integration]
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Build package
run: |
python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
dist/*.whl
dist/*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}