ci(release): update prebuilt releases file #158
Workflow file for this run
This file contains hidden or 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: Release MODFLOW executables | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| env: | |
| DIST: dist | |
| GCC_V: 12 | |
| INTEL_V: 2021.7 | |
| jobs: | |
| build: | |
| name: Build distribution | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-22.04, macos-14, windows-2022] | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v5 | |
| - name: Checkout modflow6 | |
| uses: actions/checkout@v5 | |
| with: | |
| repository: MODFLOW-ORG/modflow6 | |
| path: modflow6 | |
| - name: Setup ${{ contains(fromJSON('["macos-14"]'), matrix.os) && 'gcc' || 'intel-classic' }} ${{ contains(fromJSON('["macos-14"]'), matrix.os) && env.GCC_V || env.INTEL_V }} | |
| uses: fortran-lang/setup-fortran@v1 | |
| with: | |
| compiler: ${{ contains(fromJSON('["macos-14"]'), matrix.os) && 'gcc' || 'intel-classic' }} | |
| version: ${{ contains(fromJSON('["macos-14"]'), matrix.os) && env.GCC_V || env.INTEL_V }} | |
| - name: Setup Xcode CLT (macOS) | |
| uses: maxim-lobanov/setup-xcode@v1 | |
| if: runner.os == 'macOS' | |
| with: | |
| xcode-version: ${{ contains(fromJSON('["macos-13"]'), matrix.os) && '14.3.1' || 'latest' }} | |
| - name: Set LDFLAGS (ARM macOS) | |
| if: matrix.os == 'macos-14' | |
| run: | | |
| ldflags="$LDFLAGS -Wl,-ld_classic" | |
| echo "LDFLAGS=$ldflags" >> $GITHUB_ENV | |
| - name: Hide dylibs (ARM macOS) | |
| if: matrix.os == 'macos-14' | |
| run: | | |
| version="12" | |
| libpath="/opt/homebrew/opt/gcc@$version/lib/gcc/$version" | |
| mv $libpath/libgfortran.5.dylib $libpath/libgfortran.5.dylib.bak | |
| mv $libpath/libquadmath.0.dylib $libpath/libquadmath.0.dylib.bak | |
| mv $libpath/libstdc++.6.dylib $libpath/libstdc++.6.dylib.bak | |
| - uses: oprypin/find-latest-tag@v1 | |
| id: tag | |
| with: | |
| repository: ${{ github.repository }} | |
| releases-only: true | |
| - name: Set environment variables | |
| run: | | |
| echo "${{ github.repository }} version ${{ steps.tag.outputs.tag }}" | |
| echo "RELEASE_VERSION=${{ steps.tag.outputs.tag }}" >> $GITHUB_ENV | |
| - name: Setup pixi | |
| uses: prefix-dev/setup-pixi@v0.9.1 | |
| with: | |
| pixi-version: v0.41.4 | |
| manifest-path: modflow6/pixi.toml | |
| - name: Custom pixi install | |
| working-directory: modflow6 | |
| run: pixi run install | |
| - name: Get OS tag | |
| id: ostag | |
| run: | | |
| ostag=$(pixi run --manifest-path modflow6/pixi.toml python -c "from modflow_devtools.ostags import get_ostag; print(get_ostag())") | |
| echo "ostag=$ostag" >> $GITHUB_OUTPUT | |
| # interactive debugging | |
| # - name: Setup tmate session | |
| # uses: mxschmitt/action-tmate@v3 | |
| - name: Fetch pre-built programs | |
| run: | | |
| ostag="${{ steps.ostag.outputs.ostag }}" | |
| mkdir $ostag | |
| python3 scripts/fetch_releases.py --manifest releases.json --ostag $ostag --outdir $ostag --zip $ostag.zip | |
| - name: Build programs | |
| uses: nick-fields/retry@v3 | |
| with: | |
| shell: bash | |
| timeout_minutes: 40 | |
| command: | | |
| ostag="${{ steps.ostag.outputs.ostag }}" | |
| fetched=$(python3 scripts/fetch_releases.py --manifest releases.json --list) | |
| pixi run --manifest-path modflow6/pixi.toml make-program : --appdir $ostag --exclude "$fetched" --zip $ostag.zip --verbose | |
| pixi run --manifest-path modflow6/pixi.toml make-program mf2005,mflgr,mfnwt,mfusg --appdir $ostag --double --keep --zip $ostag.zip --verbose | |
| pixi run --manifest-path modflow6/pixi.toml make-code-json --appdir $ostag --zip $ostag.zip --verbose | |
| - name: Show programs | |
| run: | | |
| ostag="${{ steps.ostag.outputs.ostag }}" | |
| ls $ostag | |
| - name: Check linked libs (ARM macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| ostag="${{ steps.ostag.outputs.ostag }}" | |
| find $ostag -perm +111 -type f | xargs -I{} sh -c "otool -L {}" | |
| - name: Upload distribution archive | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.DIST }}-${{ matrix.os }} | |
| path: ./*.zip | |
| - name: Upload distribution metadata | |
| if: runner.os == 'Linux' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.DIST }} | |
| path: | | |
| ./code.json | |
| ./code.md | |
| # make the release if previous job was successful | |
| release: | |
| name: Make release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v3 | |
| - name: Setup Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.10" | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install https://github.com/modflowpy/pymake/zipball/master | |
| pip install https://github.com/MODFLOW-ORG/modflow-devtools/zipball/develop | |
| - name: Get last release tag | |
| id: last-tag | |
| uses: oprypin/find-latest-tag@v1 | |
| with: | |
| repository: ${{ github.repository }} | |
| releases-only: true | |
| - name: Get next release tag | |
| id: next-tag | |
| run: | | |
| current="${{ steps.last-tag.outputs.tag }}" | |
| next=$(echo "${{ steps.last-tag.outputs.tag }} + 1.0" | bc) | |
| echo "RELEASE_VERSION=$current" >> $GITHUB_ENV | |
| echo "tag=$next" >> $GITHUB_OUTPUT | |
| repo="${{ github.repository }}" | |
| echo "$repo current version is $current" | |
| echo "$repo next version is $next" | |
| - name: Download distribution | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: ${{ env.DIST }}* | |
| merge-multiple: true | |
| path: ${{ env.DIST }} | |
| - name: List distribution files | |
| run: ls -l ${{ steps.ostag.outputs.ostag }} | |
| - name: Create release body header | |
| shell: python | |
| run: | | |
| import os | |
| next_version = os.getenv('NEXT_VERSION') | |
| line = "The programs, version numbers, and the date " | |
| line += "stamp on the downloaded file used to create the " | |
| line += f"executables for version {next_version} are\n\n" | |
| with open('Header.md', "w") as file: | |
| file.write(line) | |
| - name: Build release body | |
| run: | | |
| cat Header.md ${{ env.DIST }}/code.md > BodyFile.md | |
| cat BodyFile.md | |
| # interactive debugging | |
| # - name: Setup tmate session | |
| # uses: mxschmitt/action-tmate@v3 | |
| - name: Update readme | |
| id: update-readme | |
| run: | | |
| # update readme from metadata | |
| cp ${{ env.DIST }}/code.md code.md | |
| cp ${{ env.DIST }}/code.json code.json | |
| python scripts/update_readme.py | |
| # determine whether changes need to be committed | |
| if [[ `git status --porcelain --untracked-files=no` ]]; then | |
| echo "Changes to README.md:" | |
| git diff README.md | |
| changes="true" | |
| else | |
| echo "No changes to README.md" | |
| changes="false" | |
| fi | |
| echo "changes=$changes" >> $GITHUB_OUTPUT | |
| # open PR if manual trigger | |
| - name: Draft pull request | |
| if: github.event_name == 'workflow_dispatch' && steps.update-readme.outputs.changes == 'true' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| # commit and push | |
| branch="update-readme-${{ steps.next-tag.outputs.tag }}" | |
| git config core.sharedRepository true | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add README.md | |
| git status | |
| git switch -c $branch | |
| git commit -m "ci(release): update readme" | |
| git push -u origin "$branch" | |
| # create PR | |
| body=' | |
| # MODFLOW executables release '${{ steps.next-tag.outputs.tag }}' | |
| This PR updates `README.md` with the latest release information. | |
| ' | |
| gh pr create -B "master" -H "$branch" --title "Release ${{ steps.next-tag.outputs.tag }}" --draft --body "$body" | |
| # create new release if manual trigger | |
| - name: Create release | |
| if: github.event_name == 'workflow_dispatch' | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| tag: ${{ steps.next-tag.outputs.tag }} | |
| name: "MODFLOW and related programs binary executables" | |
| bodyFile: "./BodyFile.md" | |
| artifacts: "${{ env.DIST }}/*" | |
| draft: false | |
| allowUpdates: true | |
| token: ${{ secrets.GITHUB_TOKEN }} |