|
| 1 | +# This is a basic workflow, without the standard Skyline Quality Gate. It serves as a start and an example that can be extended as required. |
| 2 | +# Important: Every change to the master or main branch will upload a new package to the Catalog using a new prerelease version. |
| 3 | +# A stable release can be done by creating a tag or a GitHub Release. |
| 4 | + |
| 5 | + |
| 6 | +name: Basic Workflow |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: [ "master", "main" ] |
| 11 | + tags: |
| 12 | + - "[0-9]+.[0-9]+.[0-9]+.[0-9]+" |
| 13 | + - "[0-9]+.[0-9]+.[0-9]+.[0-9]+-**" |
| 14 | + - "[0-9]+.[0-9]+.[0-9]+" |
| 15 | + - "[0-9]+.[0-9]+.[0-9]+-**" |
| 16 | + |
| 17 | + # Allows you to run this workflow manually from the Actions tab |
| 18 | + workflow_dispatch: |
| 19 | + |
| 20 | +jobs: |
| 21 | + build: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Validate DataMiner Secret Token |
| 27 | + id: validate-dataminer-token |
| 28 | + run: | |
| 29 | + if [[ -z "${{ secrets.DATAMINER_TOKEN }}" ]]; then |
| 30 | + echo "Error: DATAMINER_TOKEN is not set. Release not possible!" |
| 31 | + echo "Please create or re-use an admin.dataminer.services token by visiting: https://admin.dataminer.services/." |
| 32 | + echo "Navigate to the right Organization then go to Keys and create/find a key with permissions to Register catalog items, Download catalog versions and Read catalog items." |
| 33 | + echo "Copy the value of the token." |
| 34 | + repo_url="https://github.com/${{ github.repository }}/settings/secrets/actions" |
| 35 | + echo "Then set a DATAMINER_TOKEN secret in your repository settings: $repo_url" |
| 36 | + exit 1 |
| 37 | + fi |
| 38 | +
|
| 39 | + - name: Authenticate with GitHub CLI |
| 40 | + run: gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}" |
| 41 | + |
| 42 | + - name: Find Version Comment |
| 43 | + id: findVersionComment |
| 44 | + run: | |
| 45 | + echo "Checking for release notes associated with the reference: '${{ github.ref_name }}'" |
| 46 | + |
| 47 | + # Retrieve the release note body |
| 48 | + RELEASE_NOTE=$(gh release view "${{ github.ref_name }}" --json body -q '.body' 2>/dev/null || echo "") |
| 49 | + |
| 50 | + if [[ -n "$RELEASE_NOTE" ]]; then |
| 51 | + echo "Release note found for '${{ github.ref_name }}': $RELEASE_NOTE" |
| 52 | + # Escape multiline string for GITHUB_OUTPUT |
| 53 | + echo "versionComment<<EOF" >> $GITHUB_OUTPUT |
| 54 | + echo "$RELEASE_NOTE" >> $GITHUB_OUTPUT |
| 55 | + echo "EOF" >> $GITHUB_OUTPUT |
| 56 | + else |
| 57 | + echo "No release note found for '${{ github.ref_name }}'. Falling back to tag or commit message." |
| 58 | + VERSION_COMMENT=$(git describe --tags --exact-match 2>/dev/null || git log -1 --pretty=format:%s) |
| 59 | + echo "Fallback version comment: $VERSION_COMMENT" |
| 60 | + # Escape fallback as well |
| 61 | + echo "versionComment=$VERSION_COMMENT" >> $GITHUB_OUTPUT |
| 62 | + fi |
| 63 | + shell: bash |
| 64 | + |
| 65 | + - name: Test |
| 66 | + run: dotnet test -c Release |
| 67 | + |
| 68 | + - name: Publish Prerelease |
| 69 | + if: github.ref_type == 'branch' |
| 70 | + env: |
| 71 | + DATAMINER_TOKEN: ${{ secrets.DATAMINER_TOKEN }} |
| 72 | + shell: pwsh |
| 73 | + run: | |
| 74 | + dotnet publish ` |
| 75 | + -p:Version="0.0.${{ github.run_number }}" ` |
| 76 | + -p:VersionComment="${{ steps.findVersionComment.outputs.versionComment }}" ` |
| 77 | + -p:CatalogPublishKeyName="DATAMINER_TOKEN" ` |
| 78 | + -p:CatalogDefaultDownloadKeyName="DATAMINER_TOKEN" ` |
| 79 | + -c Release ` |
| 80 | +
|
| 81 | + - name: Publish Release |
| 82 | + if: github.ref_type == 'tag' |
| 83 | + env: |
| 84 | + DATAMINER_TOKEN: ${{ secrets.DATAMINER_TOKEN }} |
| 85 | + shell: pwsh |
| 86 | + run: | |
| 87 | + dotnet publish ` |
| 88 | + -p:Version="${{ github.ref_name }}" ` |
| 89 | + -p:VersionComment="${{ steps.findVersionComment.outputs.versionComment }}" ` |
| 90 | + -p:CatalogPublishKeyName="DATAMINER_TOKEN" ` |
| 91 | + -p:CatalogDefaultDownloadKeyName="DATAMINER_TOKEN" ` |
| 92 | + -c Release ` |
0 commit comments