Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated workflow #34

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 36 additions & 51 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
name: 'dotnet build'

on:
push:
branches:
- '**'
pull_request:
types: [ closed ]

workflow_dispatch:

env:
PRERELEASE_BRANCHES: experimental,alpha,beta,rc
DOCKER_IMAGE_REGISTRY_PATH: ${{ secrets.RAAEDGE_LOGIN_SERVER }}/connectors-opcua
Expand Down Expand Up @@ -35,23 +31,15 @@ jobs:
- name: Test and report coverage
run: dotnet test --configuration Release --no-build /p:CollectCoverage=true /p:CoverletOutput=${{ github.workspace }}/${{ env.COVERAGE_FOLDER }}/ /p:MergeWith=${{ github.workspace }}/${{ env.COVERAGE_FOLDER }}/coverage/ /p:CoverletOutputFormat=opencover

- name: 'ACR login'
uses: azure/docker-login@v2
with:
login-server: ${{ secrets.RAAEDGE_LOGIN_SERVER }}
username: ${{ secrets.RAAEDGE_ACR_USERNAME }}
password: ${{ secrets.RAAEDGE_ACR_PASSWORD }}

- name: Establish context
id: context
uses: dolittle/establish-context-action@v2
- uses: mathieudutour/[email protected]
name: Calculate next version and create tag on GitHub
id: tag
with:
prerelease-branches: ${{ env.PRERELEASE_BRANCHES }}

- uses: hadolint/[email protected]
with:
dockerfile: ./Source/Dockerfile
failure-threshold: error
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_prefix: ${{ inputs.component && format('{0}/v',inputs.component) || 'v' }}
fetch_all_tags: true
release_branches: ${{ inputs.branches }}
dry_run: ${{ env.RELEASE != 'true' }}

- name: Docker Build
uses: docker/build-push-action@v5
Expand All @@ -69,31 +57,34 @@ jobs:
platforms: linux/amd64
tags: ${{ env.DOCKER_IMAGE_REGISTRY_PATH }}:latest

- name: Increment version
id: increment-version
if: ${{ steps.context.outputs.should-publish == 'true' }}
uses: dolittle/increment-version-action@v2
- name: Apply version tag to Docker images
id: references
run: |
echo ${{ github.event_name }}
IMAGES=$(tr "," "\n" <<<"${{ inputs.images }}" | sed "s/^[[:space:]]*//;s/[[:space:]]*$//")
echo -e "Images to tag:\n$IMAGES"
REFS=$(sed "s/$/:v${{ steps.tag.outputs.new_version }}/" <<<"$IMAGES" | paste -sd "," -)
echo -e "References: $REFS"
echo "tags=$REFS" >> $GITHUB_OUTPUT

- name: 'ACR login'
uses: azure/docker-login@v2
with:
version: ${{ steps.context.outputs.current-version }}
release-type: ${{ steps.context.outputs.release-type }}
login-server: ${{ secrets.RAAEDGE_LOGIN_SERVER }}
username: ${{ secrets.RAAEDGE_ACR_USERNAME }}
password: ${{ secrets.RAAEDGE_ACR_PASSWORD }}

- name: Docker push
uses: docker/build-push-action@v5
if: ${{ steps.context.outputs.should-publish == 'true' && inputs.IMAGE_NAME != '' }}
uses: docker/build-push-action@v6
if: ${{ env.RELEASE == 'true' }}
with:
push: true
no-cache: true
context: .
file: ./Source/Dockerfile
build-args: |
CONFIGURATION=Release
secrets: |
NUGET_GITHUB_PACKAGES_USERNAME=${{ secrets.NUGET_GITHUB_PACKAGES_USERNAME }}
NUGET_GITHUB_PACKAGES_TOKEN=${{ secrets.NUGET_GITHUB_PACKAGES_TOKEN }}
file: ${{ inputs.dockerfile || 'Source/Dockerfile' }}
platforms: linux/amd64
tags: |
${{ env.DOCKER_IMAGE_REGISTRY_PATH }}:${{ steps.increment-version.outputs.next-version }}
${{ env.DOCKER_IMAGE_REGISTRY_PATH }}:latest
tags: ${{ steps.references.outputs.tags }}
build-args: |
BUILD_VERSION=${{ steps.tag.outputs.new_version }}

- name: Docker logout
if: always()
Expand All @@ -102,14 +93,8 @@ jobs:
docker logout ${{ secrets.RAAEDGE_LOGIN_SERVER_2 }}

- name: Create GitHub Release
uses: dolittle/github-release-action@v2
if: ${{ steps.context.outputs.should-publish == 'true' }}
with:
version: ${{ steps.increment-version.outputs.next-version }}
body: ${{ steps.context.outputs.pr-body }}

outputs:
should-publish: ${{ steps.context.outputs.should-publish }}
current-version: ${{ steps.context.outputs.current-version }}
release-type: ${{ steps.context.outputs.release-type }}
version: ${{ steps.increment-version.outputs.next-version }}
if: ${{ env.RELEASE == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ steps.tag.outputs.new_tag }} --target=${{ github.sha }} --title="${{ inputs.component && format('{0} - ',inputs.component) || '' }}v${{ steps.tag.outputs.new_version }}" --notes="${{ steps.tag.outputs.changelog }}"