|
| 1 | +name: Create Requirements Files |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + create-req-files: |
| 8 | + name: Create requirements files |
| 9 | + runs-on: ubuntu-latest |
| 10 | + strategy: |
| 11 | + matrix: |
| 12 | + python-version: ["3.7", "3.8", "3.9", "3.10"] |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v2 |
| 15 | + - name: Set up Python |
| 16 | + uses: actions/setup-python@v2 |
| 17 | + with: |
| 18 | + python-version: ${{ matrix.python-version }} |
| 19 | + - name: Display Python version |
| 20 | + run: python -c "import sys; print(sys.version)" |
| 21 | + - name: Upgrade setuptools, pip and wheel |
| 22 | + run: python -m pip install -U setuptools pip wheel |
| 23 | + - name: Install Snowflake SQLAlchemy |
| 24 | + shell: bash |
| 25 | + run: python -m pip install . |
| 26 | + - name: Generate reqs file name |
| 27 | + shell: bash |
| 28 | + run: echo "requirements_file=temp_requirement/requirements_$(python -c 'from sys import version_info;print(str(version_info.major)+str(version_info.minor))').reqs" >> $GITHUB_ENV |
| 29 | + - name: Create reqs file |
| 30 | + shell: bash |
| 31 | + run: | |
| 32 | + mkdir temp_requirement |
| 33 | + echo "# Generated on: $(python --version)" >${{ env.requirements_file }} |
| 34 | + python -m pip freeze | grep -v snowflake-sqlalchemy 1>>${{ env.requirements_file }} 2>/dev/null |
| 35 | + echo "snowflake-sqlalchemy==$(python -m pip show snowflake-sqlalchemy | grep ^Version | cut -d' ' -f2-)" >>${{ env.requirements_file }} |
| 36 | + id: create-reqs-file |
| 37 | + - name: Show created req file |
| 38 | + shell: bash |
| 39 | + run: cat ${{ env.requirements_file }} |
| 40 | + - uses: actions/upload-artifact@v2 |
| 41 | + with: |
| 42 | + path: temp_requirement |
| 43 | + |
| 44 | + push-files: |
| 45 | + needs: create-req-files |
| 46 | + name: Commit and push files |
| 47 | + runs-on: ubuntu-latest |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v2 |
| 50 | + with: |
| 51 | + token: ${{ secrets.PAT }} |
| 52 | + - name: Download requirement files |
| 53 | + uses: actions/download-artifact@v2 |
| 54 | + with: |
| 55 | + name: artifact |
| 56 | + path: tested_requirements |
| 57 | + - name: Commit and push new requirements files |
| 58 | + run: | |
| 59 | + git config user.name github-actions |
| 60 | + git config user.email [email protected] |
| 61 | + git add tested_requirements |
| 62 | + git commit -m "Update requirements files" -a |
| 63 | + git push |
0 commit comments