|
| 1 | +name: Provisional distribution |
| 2 | +on: |
| 3 | + # schedule: |
| 4 | + # - cron: '0 3 * * 3' # run at 3 AM UTC every Wednesday |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - develop |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + name: Build provisional distribution |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + os: [ubuntu-20.04, macos-12, windows-2022] |
| 16 | + defaults: |
| 17 | + run: |
| 18 | + shell: bash |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout repo |
| 22 | + uses: actions/checkout@v3 |
| 23 | + |
| 24 | + - name: Setup Intel Fortran |
| 25 | + uses: modflowpy/install-intelfortran-action@v1 |
| 26 | + |
| 27 | + # - name: Setup Intel Fortran |
| 28 | + # uses: awvwgk/setup-fortran@main |
| 29 | + # with: |
| 30 | + # compiler: intel-classic |
| 31 | + # version: 2021.7.0 |
| 32 | + |
| 33 | + - name: Setup Python |
| 34 | + uses: actions/setup-python@v4 |
| 35 | + with: |
| 36 | + python-version: 3.9 |
| 37 | + |
| 38 | + - name: Install Python dependencies |
| 39 | + run: | |
| 40 | + python -m pip install --upgrade pip |
| 41 | + pip install https://github.com/modflowpy/pymake/zipball/master |
| 42 | + pip install modflow-devtools |
| 43 | + pip list |
| 44 | + |
| 45 | + - name: Get OS tag |
| 46 | + id: get-ostag |
| 47 | + shell: python |
| 48 | + run: | |
| 49 | + from os import environ |
| 50 | + from modflow_devtools.ostags import get_modflow_ostag |
| 51 | + with open(environ.get("GITHUB_OUTPUT"), "a") as f: |
| 52 | + f.write(f"ostag={get_modflow_ostag()}") |
| 53 | + |
| 54 | + - name: Get date |
| 55 | + uses: josStorer/get-current-time@v2 |
| 56 | + id: current-time |
| 57 | + with: |
| 58 | + format: YYYYMMDD |
| 59 | + |
| 60 | + - name: Get short SHA |
| 61 | + uses: benjlevesque/[email protected] |
| 62 | + id: short-sha |
| 63 | + |
| 64 | + - name: Get exe name |
| 65 | + id: exe-name |
| 66 | + run: echo "name=mp7_${{ steps.get-ostag.outputs.ostag }}_${{ steps.current-time.outputs.formattedTime }}_${{ steps.short-sha.outputs.sha }}" >> $GITHUB_OUTPUT |
| 67 | + |
| 68 | + - name: Build executable |
| 69 | + if: runner.os != 'Windows' |
| 70 | + run: mfpymake source ${{ steps.exe-name.outputs.name }} -ad msvs/bin_PROVISIONAL -fc ifort |
| 71 | + |
| 72 | + - name: Build executable (Windows) |
| 73 | + if: runner.os == 'Windows' |
| 74 | + shell: cmd |
| 75 | + run: mfpymake source ${{ steps.exe-name.outputs.name }}.exe -ad msvs\bin_PROVISIONAL -fc ifort |
| 76 | + |
| 77 | + - name: Upload executable |
| 78 | + if: runner.os != 'Windows' |
| 79 | + uses: actions/upload-artifact@v3 |
| 80 | + with: |
| 81 | + name: ${{ steps.exe-name.outputs.name }} |
| 82 | + path: msvs/bin_PROVISIONAL/${{ steps.exe-name.outputs.name }} |
| 83 | + |
| 84 | + - name: Upload executable (Windows) |
| 85 | + if: runner.os == 'Windows' |
| 86 | + uses: actions/upload-artifact@v3 |
| 87 | + with: |
| 88 | + name: ${{ steps.exe-name.outputs.name }} |
| 89 | + path: msvs/bin_PROVISIONAL/${{ steps.exe-name.outputs.name }}.exe |
| 90 | + |
| 91 | + commit: |
| 92 | + name: Commit and push executable |
| 93 | + # if: github.repository_owner == 'MODFLOW-USGS' |
| 94 | + needs: build |
| 95 | + runs-on: ubuntu-22.04 |
| 96 | + permissions: |
| 97 | + contents: write |
| 98 | + defaults: |
| 99 | + run: |
| 100 | + shell: bash |
| 101 | + steps: |
| 102 | + |
| 103 | + - name: Checkout repo |
| 104 | + uses: actions/checkout@v3 |
| 105 | + |
| 106 | + - name: Remove old binaries |
| 107 | + working-directory: msvs/bin_PROVISIONAL |
| 108 | + if: runner.os == 'Linux' |
| 109 | + run: rm -rf mp7* |
| 110 | + |
| 111 | + - name: Download binaries |
| 112 | + uses: actions/download-artifact@v3 |
| 113 | + with: |
| 114 | + path: msvs/bin_PROVISIONAL |
| 115 | + |
| 116 | + - name: Get short SHA |
| 117 | + uses: benjlevesque/[email protected] |
| 118 | + id: short-sha |
| 119 | + |
| 120 | + - name: Commit and push |
| 121 | + working-directory: msvs/bin_PROVISIONAL |
| 122 | + if: runner.os == 'Linux' |
| 123 | + run: | |
| 124 | + # configure git |
| 125 | + git config core.sharedRepository true |
| 126 | + git config user.name "github-actions[bot]" |
| 127 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 128 | +
|
| 129 | + echo "shortening nested dir names" |
| 130 | + date=$(date +%Y%m%d) |
| 131 | + find mp7* -type d | sed -e "p;s/_$date.*$//" | xargs -n2 mv |
| 132 | +
|
| 133 | + echo "moving exes to top-level bin dir" |
| 134 | + for file in mp7*/*; do |
| 135 | + mv $file $(basename $file) |
| 136 | + done |
| 137 | +
|
| 138 | + echo "removing empty nested dirs" |
| 139 | + find mp7* -type d -delete |
| 140 | +
|
| 141 | + # commit and push |
| 142 | + git add . |
| 143 | + git commit -m "add binaries built from ${{ github.sha }}" |
| 144 | + git push origin "${{ github.ref_name }}" |
0 commit comments