Skip to content

feat: add .NET 9.0 to target frameworks (#190) #33

feat: add .NET 9.0 to target frameworks (#190)

feat: add .NET 9.0 to target frameworks (#190) #33

Workflow file for this run

name: Release
on:
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}"
export RELEASE_MAJOR_VERSION="${RELEASE_VERSION%%.*}"
export remaining_version="${RELEASE_VERSION#*.}"
export RELEASE_MINOR_VERSION="${RELEASE_MAJOR_VERSION}.${remaining_version%%.*}"
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT
echo "RELEASE_MINOR_VERSION=$RELEASE_MINOR_VERSION" >> $GITHUB_OUTPUT
echo "RELEASE_MAJOR_VERSION=$RELEASE_MAJOR_VERSION" >> $GITHUB_OUTPUT
outputs:
RELEASE_VERSION: ${{ steps.get-version-tag.outputs.RELEASE_VERSION }}
RELEASE_MINOR_VERSION: ${{ steps.get-version-tag.outputs.RELEASE_MINOR_VERSION }}
RELEASE_MAJOR_VERSION: ${{ steps.get-version-tag.outputs.RELEASE_MAJOR_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 --property:Version=${{ needs.version.outputs.RELEASE_VERSION }}
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 }}
export PackageSource=${PackageSource:="https://api.nuget.org/v3/index.json"}
echo "PackageSource=${PackageSource}" >> $GITHUB_ENV
dotnet pack --configuration Release --output artifacts --property:Version=${{ needs.version.outputs.RELEASE_VERSION }}
- name: Push
run: dotnet nuget push "*" -s ${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: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
bagetter/bagetter:latest
bagetter/bagetter:${{ needs.version.outputs.RELEASE_VERSION }}
bagetter/bagetter:${{ needs.version.outputs.RELEASE_MINOR_VERSION }}
bagetter/bagetter:${{ needs.version.outputs.RELEASE_MAJOR_VERSION }}
build-args: |
Version=${{ needs.version.outputs.RELEASE_VERSION }}
release_helm_chart:
if: ${{ github.ref_type == 'tag' }}
needs: [version, verify]
name: Release Helm chart to GitHub
runs-on: ubuntu-latest
env:
CHART_DIR: deployment templates/chart
CHART_REPO: bagetter/helm-chart-repo
CHART_REPO_BRANCH: master
steps:
- uses: actions/[email protected]
- name: Update version in helm chart
run: |
sed -i "s/version: \".*\"/version: \"${{ needs.version.outputs.RELEASE_VERSION }}\"/" "deployment templates/chart/bagetter/Chart.yaml"
sed -i "s/appVersion: \".*\"/appVersion: \"${{ needs.version.outputs.RELEASE_VERSION }}\"/" "deployment templates/chart/bagetter/Chart.yaml"
- name: Generate helm docs
uses: losisin/helm-docs-github-action@v1
with:
chart-search-root: "deployment templates"
- name: Install yq - portable yaml processor
uses: mikefarah/[email protected]
- name: Collect charts
id: charts
run: |
set -e
find -L '${{ env.CHART_DIR }}' -mindepth 2 -maxdepth 2 -type f \( -name 'Chart.yaml' -o -name 'Chart.yml' \) -exec dirname "{}" \; \
| sort -u \
| sed -E 's/^/- /' \
| yq --no-colors --indent 0 --output-format json '.' \
| sed -E 's/^/charts=/' >> $GITHUB_OUTPUT
- name: Install chart releaser
run: |
set -e
arch="$(dpkg --print-architecture)"
curl -s https://api.github.com/repos/helm/chart-releaser/releases/latest \
| yq --indent 0 --no-colors --input-format json --unwrapScalar \
".assets[] | select(.name | test("\""^chart-releaser_.+_linux_${arch}\.tar\.gz$"\"")) | .browser_download_url" \
| xargs curl -SsL \
| tar zxf - -C /usr/local/bin
- name: Install Helm
uses: azure/[email protected]
- name: Helm Deps
run: |
set -ex
echo '${{ steps.charts.outputs.charts }}' \
| yq --indent 0 --no-colors --input-format json --unwrapScalar '.[]' \
| while read -r dir; do
helm dependency update "$dir";
if [ -f "$dir/Chart.lock" ]; then
yq --indent 0 \
'.dependencies | map(["helm", "repo", "add", .name, .repository] | join(" ")) | .[]' \
"$dir/Chart.lock" \
| sh --;
fi
done
- name: Package charts
id: package
run: |
set -ex
PACKAGES=.cr-release-packages
echo '${{ steps.charts.outputs.charts }}' \
| yq --indent 0 --no-colors --input-format json --unwrapScalar '.[]' \
| xargs -d$'\n' cr package --package-path "$PACKAGES"
echo "dir=${PACKAGES}" >> $GITHUB_OUTPUT
- name: Upload packages
run: |
set -ex
git config --list
owner=$(cut -d '/' -f 1 <<< '${{ env.CHART_REPO }}')
repo=$(cut -d '/' -f 2 <<< '${{ env.CHART_REPO }}')
cr upload --commit '${{ github.sha }}' --git-repo "$repo" --owner "$owner" --token '${{ github.token }}' \
--package-path '${{ steps.package.outputs.dir }}' --skip-existing
- name: Update charts index
working-directory: .helm-chart-repo
run: |
set -ex
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
mkdir -p .cr-index
owner=$(cut -d '/' -f 1 <<< '${{ env.CHART_REPO }}')
repo=$(cut -d '/' -f 2 <<< '${{ env.CHART_REPO }}')
cr index --git-repo "$repo" --owner "$owner" --pages-branch '${{ env.CHART_REPO_BRANCH }}' \
--package-path '../${{ steps.package.outputs.dir }}' \
--index-path .cr-index --push