Merge pull request #4 from uit-no/fix-release-yml #1
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: singularity-deploy | |
on: | |
push: | |
branches: | |
- "main" | |
jobs: | |
release: | |
name: Create release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Get latest tag | |
run: | | |
# Get the latest tag, we won't build if it's the current | |
git fetch --tags | |
latest_tag=$(git tag | tail -1) | |
echo "latest_tag=$latest_tag" >> $GITHUB_ENV | |
- name: Define repository name and release version | |
run: | | |
release=$(cat VERSION) | |
echo "release_tag=$release" >> $GITHUB_ENV | |
- name: Create release | |
id: create_release | |
uses: actions/create-release@v1 | |
if: ${{ env.release_tag != env.latest_tag }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.release_tag }} | |
release_name: Release ${{ env.release_tag }} | |
draft: false | |
prerelease: false | |
- uses: eWaterCycle/setup-singularity@v6 | |
if: ${{ env.release_tag != env.latest_tag }} | |
with: | |
singularity-version: 3.7.1 | |
- name: Build the singularity container | |
if: ${{ env.release_tag != env.latest_tag }} | |
run: | | |
# For each Singularity* container, build based on the prefix (tag) | |
for recipe in $(ls Singularity*); do | |
echo "Building $recipe" | |
tag=$(echo "${recipe/Singularity\./}") | |
# If we find empty, use latest | |
if [ "$tag" == "Singularity" ]; then | |
tag=latest | |
fi | |
# Build the container and name by tag | |
echo "Tag is $tag." | |
container="$tag.sif" | |
singularity build --fakeroot container.sif "$recipe" | |
if [ "$?" == "0" ]; then | |
echo "Successfully built container $container." | |
mv container.sif "$container" | |
else | |
echo "There was an issue building $container." | |
fi | |
done | |
- name: Upload release assets | |
if: ${{ env.release_tag != env.latest_tag }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
tag_name: ${{ env.release_tag }} | |
run: | | |
hub release edit $(find . -type f -name "*.sif" -printf "-a %p ") -m "" "$tag_name" |