Source parsing: consider end program
with no program
header
#1324
Workflow file for this run
This file contains 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 | |
on: | |
push: | |
pull_request: | |
release: | |
types: [published] | |
jobs: | |
source-archive: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
format: [zip] | |
env: | |
FORMAT: ${{ matrix.format }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get version number | |
run: | | |
VERSION=$(git describe --tags --match 'v*' --always | tr -d 'v') | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
- name: Create archive | |
run: | | |
echo "OUTPUT=${{ env.OUTPUT }}" >> $GITHUB_ENV | |
git archive --prefix ${{ env.PREFIX }} --format ${{ env.FORMAT }} HEAD > ${{ env.OUTPUT }} | |
env: | |
OUTPUT: fpm-${{ env.VERSION }}.${{ env.FORMAT }} | |
PREFIX: fpm-${{ env.VERSION }}/ | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.OUTPUT }} | |
path: ${{ env.OUTPUT }} | |
source-single-file: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get version number | |
run: | | |
VERSION=$(git describe --tags --match 'v*' --always | tr -d 'v') | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
echo ${{ env.VERSION }} | |
- name: Get manifest version | |
run: | | |
MANIFEST_VERSION=$(grep version fpm.toml | head -1 | tr -d ' ' | tr -d 'version=') | |
echo "MANIFEST_VERSION=${MANIFEST_VERSION}" >> $GITHUB_ENV | |
echo ${{ env.MANIFEST_VERSION }} | |
# Note: this step is meant to remove the test targets from the package manifest, | |
# a change in the package manifest might require to regenerate the patch file. | |
- name: Remove tests | |
run: | | |
patch -p1 < ./ci/single-file.patch | |
- name: Install fpm | |
uses: fortran-lang/setup-fpm@v5 | |
with: | |
fpm-version: 'v0.8.0' | |
- name: Create single file version | |
run: | | |
echo "OUTPUT=${{ env.OUTPUT }}" >> $GITHUB_ENV | |
echo "#define FPM_BOOTSTRAP" > fpm-${{ env.VERSION }}.F90 | |
# We need to pass the exact version string that a fpm build command would send | |
echo "#define FPM_RELEASE_VERSION ${{ env.MANIFEST_VERSION }}" >> fpm-${{ env.VERSION }}.F90 | |
# Intel compiler predefines "linux" and "unix" which causes inadvertent substitutions | |
echo "#undef linux" >> fpm-${{ env.VERSION }}.F90 | |
echo "#undef unix" >> fpm-${{ env.VERSION }}.F90 | |
fpm build --compiler ./ci/single-file-gfortran.sh | |
env: | |
OUTPUT: fpm-${{ env.VERSION }}.F90 | |
OMP_NUM_THREADS: 1 | |
# Building the bootstrap version from the single source version is the most expensive | |
# step in this workflow, since we have to compile several thousand lines of source. | |
- name: Build single source version | |
run: | | |
echo "EXE=${{ env.BUILD_DIR }}/fpm" >> $GITHUB_ENV | |
mkdir ${{ env.BUILD_DIR }} | |
gfortran ${{ env.OUTPUT }} -J ${{ env.BUILD_DIR }} -o ${{ env.BUILD_DIR }}/fpm | |
env: | |
BUILD_DIR: build/bootstrap | |
- name: Undo patch | |
run: | | |
patch -p1 -R < ./ci/single-file.patch | |
- name: Build fpm with bootstrap version | |
run: | | |
${{ env.EXE }} build | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.OUTPUT }} | |
path: ${{ env.OUTPUT }} | |
upload-artifacts: | |
if: ${{ github.event_name == 'release' && contains(github.ref, 'v') || github.event_name == 'push' }} | |
runs-on: ubuntu-latest | |
needs: | |
- source-archive | |
- source-single-file | |
steps: | |
- id: deploy-on-push | |
if: ${{ github.event_name == 'push' }} | |
run: | |
echo "::set-output name=result::${{ env.DEPLOY_BRANCH }}" | |
env: | |
DEPLOY_BRANCH: ${{ secrets.DEPLOY_BRANCH && contains(github.ref, secrets.DEPLOY_BRANCH) && 1 || 0 }} | |
- uses: actions/checkout@v4 | |
if: ${{ github.event_name == 'push' }} | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: fpm-cd-artifacts | |
merge-multiple: true | |
- name: Normalize file names for continuous delivery | |
if: ${{ github.event_name == 'push' }} | |
run: | | |
cd fpm-cd-artifacts | |
for output in fpm-*; do | |
mv -v $(basename $output) $(basename $output | sed -E '${{ env.replace }}') | |
done | |
env: | |
replace: 's/-([0-9]+\.[0-9]+\.[0-9]+-[0-9]+-g)?[0-9a-f]+//' | |
- name: Create SHA256 checksums | |
run: | | |
cd fpm-cd-artifacts | |
for output in fpm-*; do | |
sha256sum $(basename "$output") | tee $(basename "$output").sha256 | |
done | |
- name: Move/Create continuous tag | |
if: ${{ github.event_name == 'push' && steps.deploy-on-push.outputs.result != 0 }} | |
run: | | |
git tag --force 'current' ${{ github.sha }} | |
git push --tags --force | |
- name: Upload assets | |
if: ${{ github.event_name == 'release' || steps.deploy-on-push.outputs.result != 0 }} | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: fpm-cd-artifacts/* | |
file_glob: true | |
tag: ${{ github.event_name == 'release' && github.ref || 'current'}} | |
overwrite: true |