|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + release: |
| 7 | + types: [published] |
| 8 | + |
| 9 | +jobs: |
| 10 | + source-archive: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + format: [zip] |
| 16 | + env: |
| 17 | + FORMAT: ${{ matrix.format }} |
| 18 | + steps: |
| 19 | + - name: Checkout code |
| 20 | + uses: actions/checkout@v2 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Get version number |
| 25 | + run: | |
| 26 | + VERSION=$(git describe --tags --match 'v*' --always | tr -d 'v') |
| 27 | + echo "VERSION=${VERSION}" >> $GITHUB_ENV |
| 28 | +
|
| 29 | + - name: Create archive |
| 30 | + run: | |
| 31 | + echo "OUTPUT=${{ env.OUTPUT }}" >> $GITHUB_ENV |
| 32 | + git archive --prefix ${{ env.PREFIX }} --format ${{ env.FORMAT }} HEAD > ${{ env.OUTPUT }} |
| 33 | + env: |
| 34 | + OUTPUT: fpm-${{ env.VERSION }}.${{ env.FORMAT }} |
| 35 | + PREFIX: fpm-${{ env.VERSION }}/ |
| 36 | + |
| 37 | + - name: Upload artifact |
| 38 | + uses: actions/upload-artifact@v2 |
| 39 | + with: |
| 40 | + name: ${{ env.OUTPUT }} |
| 41 | + path: ${{ env.OUTPUT }} |
| 42 | + |
| 43 | + source-single-file: |
| 44 | + runs-on: ubuntu-latest |
| 45 | + steps: |
| 46 | + - name: Checkout code |
| 47 | + uses: actions/checkout@v2 |
| 48 | + with: |
| 49 | + fetch-depth: 0 |
| 50 | + |
| 51 | + - name: Get version number |
| 52 | + run: | |
| 53 | + VERSION=$(git describe --tags --match 'v*' --always | tr -d 'v') |
| 54 | + echo "VERSION=${VERSION}" >> $GITHUB_ENV |
| 55 | +
|
| 56 | + # Note: this step is meant to remove the test targets from the package manifest, |
| 57 | + # a change in the package manifest might require to regenerate the patch file. |
| 58 | + - name: Remove tests |
| 59 | + run: | |
| 60 | + patch -p1 < ./ci/single-file.patch |
| 61 | +
|
| 62 | + - name: Install fpm |
| 63 | + uses: fortran-lang/setup-fpm@v3 |
| 64 | + with: |
| 65 | + fpm-version: 'v0.4.0' |
| 66 | + |
| 67 | + - name: Create single file version |
| 68 | + run: | |
| 69 | + echo "OUTPUT=${{ env.OUTPUT }}" >> $GITHUB_ENV |
| 70 | + echo "#define FPM_BOOTSTRAP" > fpm-${{ env.VERSION }}.F90 |
| 71 | + fpm build --compiler ./ci/single-file-gfortran.sh |
| 72 | + env: |
| 73 | + OUTPUT: fpm-${{ env.VERSION }}.F90 |
| 74 | + OMP_NUM_THREADS: 1 |
| 75 | + |
| 76 | + # Building the bootstrap version from the single source version is the most expensive |
| 77 | + # step in this workflow, since we have to compile several thousand lines of source. |
| 78 | + - name: Build single source version |
| 79 | + run: | |
| 80 | + echo "EXE=${{ env.BUILD_DIR }}/fpm" >> $GITHUB_ENV |
| 81 | + mkdir ${{ env.BUILD_DIR }} |
| 82 | + gfortran ${{ env.OUTPUT }} -J ${{ env.BUILD_DIR }} -o ${{ env.BUILD_DIR }}/fpm |
| 83 | + env: |
| 84 | + BUILD_DIR: build/bootstrap |
| 85 | + |
| 86 | + - name: Undo patch |
| 87 | + run: | |
| 88 | + patch -p1 -R < ./ci/single-file.patch |
| 89 | +
|
| 90 | + - name: Build fpm with bootstrap version |
| 91 | + run: | |
| 92 | + ${{ env.EXE }} build |
| 93 | +
|
| 94 | + - name: Upload artifact |
| 95 | + uses: actions/upload-artifact@v2 |
| 96 | + with: |
| 97 | + name: ${{ env.OUTPUT }} |
| 98 | + path: ${{ env.OUTPUT }} |
| 99 | + |
| 100 | + upload-artifacts: |
| 101 | + if: github.event_name == 'release' |
| 102 | + runs-on: ubuntu-latest |
| 103 | + needs: |
| 104 | + - source-archive |
| 105 | + - source-single-file |
| 106 | + |
| 107 | + steps: |
| 108 | + - name: Download Artifacts |
| 109 | + uses: actions/download-artifact@v2 |
| 110 | + with: |
| 111 | + path: ${{ github.workspace }} # This will download all files |
| 112 | + |
| 113 | + - name: Create SHA256 checksums |
| 114 | + run: | |
| 115 | + for output in fpm-*/fpm-*; do |
| 116 | + pushd $(dirname "$output") |
| 117 | + sha256sum $(basename "$output") | tee $(basename "$output").sha256 |
| 118 | + popd |
| 119 | + done |
| 120 | +
|
| 121 | + - name: Upload assets |
| 122 | + if: ${{ github.event_name == 'release' }} |
| 123 | + uses: svenstaro/upload-release-action@v2 |
| 124 | + with: |
| 125 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 126 | + file: fpm-*/fpm-* |
| 127 | + file_glob: true |
| 128 | + tag: ${{ github.ref }} |
| 129 | + overwrite: true |
0 commit comments