Skip to content

Commit

Permalink
actions++
Browse files Browse the repository at this point in the history
  • Loading branch information
vpenades committed May 20, 2024
1 parent 1e82e37 commit ee14da4
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 11 deletions.
15 changes: 15 additions & 0 deletions .github/actions/Build/FormatSemver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# set input or default

DEFAULTPACKAGEVERSION="1.0.0-Test-DATE-TIME"
PACKAGEVERSION=${1:-$DEFAULTPACKAGEVERSION}

# replace date
DATE_SHORT=$(date +'%Y%m%d')
PACKAGEVERSION="${PACKAGEVERSION/DATE/$DATE_SHORT}"

# replace time
TIME_SHORT=$(date +'%H%M%S')
PACKAGEVERSION="${PACKAGEVERSION/TIME/$TIME_SHORT}"

# report semver
echo "GHENV_PACKAGEVERSION=$PACKAGEVERSION"
31 changes: 31 additions & 0 deletions .github/actions/Build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: 'Build packages and store artifacts'
description: 'Build packages and store artifacts'

inputs:
nuget-semver:
description: 'package version'
required: false
default: '1.0.0-Test-DATE-TIME'

runs:
using: 'composite'

steps:

- name: Setup .NET SDK
uses: actions/setup-dotnet@v4

- name: Build
run: |
chmod +x ./SharpGLTF.Build.sh
./SharpGLTF.Build.sh ${{inputs.nuget-semver}}
shell: bash

- name: Archive
uses: actions/upload-artifact@v4
with:
name: nuget-packages
retention-days: 1
path: |
*.nupkg
*.snupkg
38 changes: 38 additions & 0 deletions .github/actions/PushGithubTag/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: 'Push Github Tag'
description: 'Pushes a new github tag from Master'

inputs:
tag-name:
description: 'name of the tag'
required: true
default: 'tag'
message:
description: 'message'
required: false
default: 'message'

runs:
using: 'composite'

steps:

# - name: Checkout
# uses: actions/checkout@v4

# https://github.com/orgs/community/discussions/40405
- run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
git tag -a "${{inputs.tag-name}}" -m "${{inputs.message}}"
git push origin "${{inputs.tag-name}}"
shell: bash
# # alternative solution:
# # https://github.com/rickstaa/action-create-tag
# - name: create tag
# uses: rickstaa/action-create-tag@v1
# id: "tag_create"
# with:
# tag: "${{inputs.tag-name}}"
# tag_exists_error: true
# message: "${{inputs.message}}"
13 changes: 5 additions & 8 deletions .github/workflows/PublishToGithub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ jobs:
- name: Push to NuGet
run: dotnet nuget push "*.nupkg" --api-key ${{secrets.SharpGLTF_PublishToGithub}} --source https://nuget.pkg.github.com/${{github.repository_owner}}

tag_job: #---------------------------------------------------------------------------------------
needs: [ prepare_job, build_job ]
permissions:
contents: write # required for pushing the tag
uses: ./.github/workflows/PushGithubTag.yml
with:
tag-name: "${{needs.prepare_job.outputs.semver}}"
message: "Tag for ${{needs.prepare_job.outputs.semver}}"
- name: create tag
uses: ./.github/actions/PushGithubTag
with:
tag-name: "${{env.GHENV_PACKAGEVERSION}}"
message: "new tag for ${{env.GHENV_PACKAGEVERSION}}"
29 changes: 26 additions & 3 deletions .github/workflows/PublishToNuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,29 @@ on: workflow_dispatch

jobs:

build_job:
prepare_job: #---------------------------------------------------------------------------------------
runs-on: ubuntu-latest

steps:

- name: Checkout
uses: actions/checkout@v4

- name: Define Version at GHENV_PACKAGEVERSION
run: |
chmod +x ./.github/workflows/FormatSemver.sh
./.github/workflows/FormatSemver.sh "${{ vars.SharpGLTF_Version }}-Alpha${{ vars.SharpGLTF_AlphaVersion }}" >> $GITHUB_ENV
outputs:
semver: "${{env.GHENV_PACKAGEVERSION}}"

build_job: #---------------------------------------------------------------------------------------
needs: prepare_job
uses: ./.github/workflows/BuildPackages.yml
with:
nuget-semver: ${{ vars.SharpGLTF_Version }}-alpha${{ vars.SharpGLTF_AlphaVersion }}
nuget-semver: "${{needs.prepare_job.outputs.semver}}"

publish_job:
publish_job: #---------------------------------------------------------------------------------------
needs: build_job
runs-on: ubuntu-latest

Expand All @@ -22,3 +39,9 @@ jobs:

- name: Push to NuGet
run: dotnet nuget push "*.nupkg" --api-key ${{secrets.SharpGLTF_PublishToNuget}} --source https://api.nuget.org/v3/index.json

- name: create tag
uses: ./.github/actions/PushGithubTag
with:
tag-name: "${{env.GHENV_PACKAGEVERSION}}"
message: "new tag for ${{env.GHENV_PACKAGEVERSION}}"

0 comments on commit ee14da4

Please sign in to comment.