Skip to content

Generate a zip file for GitHub during a release (#60) #14

Generate a zip file for GitHub during a release (#60)

Generate a zip file for GitHub during a release (#60) #14

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
releaseVersion:
description: 'Release version'
required: true
default: '0.0.0'
packageSource:
description: 'Package source'
required: true
default: 'https://api.nuget.org/v3/index.json'
push:
tags:
- 'v*.*.*'
jobs:
version:
runs-on: ubuntu-latest
steps:
- id: get-version-tag
run: |
export GITHUB_REF_NAME="${{ github.ref_name }}"
export RELEASE_VERSION="${GITHUB_REF_NAME#v}"
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT
outputs:
RELEASE_VERSION: ${{ steps.get-version-tag.outputs.RELEASE_VERSION }}
verify:
name: Run tests
runs-on: ubuntu-latest
needs: version
steps:
- uses: actions/[email protected]
- name: Setup .NET
uses: actions/[email protected]
with:
global-json-file: global.json
- name: Test
run: dotnet test --verbosity normal
release_zip:
if: ${{ github.ref_type == 'tag' }}
needs: [version, verify]
name: Release BaGetter.zip to GitHub
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/[email protected]
with:
global-json-file: global.json
- name: Publish
run: |
dotnet publish src/BaGetter --configuration Release --output artifacts
echo ${{ github.sha }} > artifacts/ReleaseSha.txt
7z a -tzip bagetter-${{ needs.version.outputs.RELEASE_VERSION }}.zip ./artifacts/*
- name: Generate changelog with git-cliff
uses: tj-actions/[email protected]
with:
args: --latest --strip all
output: "CHANGELOG.md"
- name: Create release with ncipollo/release-action
uses: ncipollo/[email protected]
with:
bodyFile: "CHANGELOG.md"
artifacts: "bagetter-${{ needs.version.outputs.RELEASE_VERSION }}.zip"
name: ${{ needs.version.outputs.RELEASE_VERSION }}
prerelease: ${{ contains(github.ref_name, '-') }}
release_packages:
if: ${{ github.ref_type == 'tag' }}
needs: [version, verify]
name: Release packages to nuget.org
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Setup .NET
uses: actions/[email protected]
with:
global-json-file: global.json
- name: Pack
run: |
export PackageVersion=${{ needs.version.outputs.RELEASE_VERSION }}
dotnet pack --configuration Release --output artifacts
- name: Push
run: dotnet nuget push "*" -s ${{ github.event.inputs.packageSource }} -k ${{secrets.NUGET_API_KEY}}
working-directory: artifacts
release_docker_image:
if: ${{ github.ref_type == 'tag' }}
needs: [version, verify]
name: Release Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set release version
run: echo "PackageVersion=${{ needs.version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
push: true
tags: |
bagetter/bagetter:latest
bagetter/bagetter:${{ needs.version.outputs.RELEASE_VERSION }}