Skip to content

Nuget packaging brought into line with docker publish #1

Nuget packaging brought into line with docker publish

Nuget packaging brought into line with docker publish #1

name: publish
on:
release:
types: [ published ]
tags:
- v*
env:
IMAGE_NAME: not-again-api
USER_PATH: ${{ secrets.DOCKER_REPO_USER }}
HUB_FOLDER: ${{ secrets.DOCKER_HUB_FOLDER }}
jobs:
# Run tests.
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
# (TO DO)
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Log into registry
run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login docker.io -u $USER_PATH --password-stdin
- name: Build image
run: docker build --file ./src/6.0/Not.Again.Api.Host/Dockerfile --build-arg PAT=${{ secrets.PACKAGE_FEED_TOKEN }} --tag $IMAGE_NAME ./src/6.0 #
- name: Push image
run: |
IMAGE_ID=docker.io/$HUB_FOLDER/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:latest
docker push $IMAGE_ID:$VERSION
docker push $IMAGE_ID:latest
nuget:
runs-on: ubuntu-latest
env:
SOLUTION_PATH: ./src/6.0
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore $SOLUTION_PATH
- name: Build
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')

Check failure on line 68 in .github/workflows/publish-version.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/publish-version.yml

Invalid workflow file

You have an error in your yaml syntax on line 68
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
dotnet build $SOLUTION_PATH --no-restore --ignore-failed-sources /p:Version=$VERSION -c Release
- name: Create output folder
run: mkdir ./output
- name: Consolidate packages (including symbols)
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
find . -name "*$VERSION.*nupkg" -type f -exec cp {} ./output \;
- name: Echo packages
run: find ./output -name "*.*nupkg" -type f -exec echo {} \;
- name: Push
run: find ./output -name "*.nupkg" -type f -exec dotnet nuget push "{}" --api-key ${{ secrets.NUGET_ORG_API_KEY }} --source "https://api.nuget.org/v3/index.json" \;