Deploy #34
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
# There is no manual way to call this out to run this on tags via UI. | |
# See: https://github.community/t/workflow-dispatch-from-a-tag-in-actions-tab/130561 | |
on: workflow_dispatch | |
name: Deploy | |
jobs: | |
check-if-tag: | |
name: Set Package Version | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{steps.deployment.outputs.version}} | |
steps: | |
- name: Checkout | |
run: | | |
REPOSITORY="https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}.git" | |
BRANCH="${GITHUB_REF/#refs\/heads\//}" | |
git version | |
git clone --no-checkout ${REPOSITORY} . | |
git config --local gc.auto 0 | |
git -c protocol.version=2 fetch --no-tags --prune --progress --depth=2 origin +${GITHUB_SHA}:refs/remotes/origin/${BRANCH} | |
git checkout --progress --force -B $BRANCH refs/remotes/origin/$BRANCH | |
- name: Set Variables | |
id: deployment | |
shell: bash | |
run: | | |
if [ $(git describe --exact-match --tags HEAD &> /dev/null; echo $?) == 0 ]; then | |
echo "::set-output name=VERSION::$(git describe --exact-match --tags HEAD)" | |
else | |
echo "fatal: no tag detected for HEAD. Workflow will now stop." | |
exit 128; | |
fi | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: check-if-tag | |
environment: Deploy | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Set Artifacts Directory | |
id: artifactsPath | |
run: echo "::set-output name=NUGET_ARTIFACTS::${{github.workspace}}/artifacts" | |
- name: Setup .NET 6.0.x | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: "6.0.x" | |
- name: Pack | |
run: | | |
dotnet pack -c Release LocalisationAnalyser /p:Version=${{needs.check-if-tag.outputs.version}} /p:GenerateDocumentationFile=true -o ${{steps.artifactsPath.outputs.nuget_artifacts}} | |
dotnet pack -c Release LocalisationAnalyser.Tools /p:Version=${{needs.check-if-tag.outputs.version}} /p:GenerateDocumentationFile=true -o ${{steps.artifactsPath.outputs.nuget_artifacts}} | |
- name: Deploy | |
run: | | |
dotnet nuget push ${{github.workspace}}/artifacts/*.nupkg --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key ${{secrets.NUGET_API_KEY}} |