Skip to content

Update release.yml

Update release.yml #25

Workflow file for this run

name: Release CSGHub
on:
push:
tags:
- 'v*'
jobs:
release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 50
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v4
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.6.0
with:
charts_dir: helm-chart/charts
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Package Custom Artifact
id: package_artifact
run: |
docker_artifact="csghub-docker-compose-${{ github.ref_name }}.tgz"
chart_artifact="csghub-helm-chart-${{ github.ref_name }}.tgz"
tar -zcf $docker_artifact docker-compose/csghub
tar -zcf $chart_artifact helm-chart/charts/csghub
echo "artifacts=$docker_artifact,$chart_artifact" >> $GITHUB_OUTPUT
- name: Check if Release Exists
id: check_if_exists
run: |
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.ref_name }}")
if echo "$response" | grep -q "id"; then
upload_url=$(echo "$response" | jq -r '.upload_url')
echo "release_exists=true" >> $GITHUB_ENV
echo "upload_url=$upload_url" >> $GITHUB_OUTPUT
else
echo "release_exists=false" >> $GITHUB_ENV
fi
- name: Upload Release Assets
if: env.release_exists == 'true'
uses: softprops/action-gh-release@v2
with:
files: |
${{ steps.package_artifact.outputs.artifacts }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Detailed Release Notes
id: generate_detailed_release_notes
if: env.release_exists == 'false'
run: |
ALL_TAGS=$(git tag --sort=-v:refname)
CURRENT_TAG=${GITHUB_REF#refs/tags/}
PREVIOUS_TAG=$(echo "$ALL_TAGS" | grep -F -x -A 1 "$CURRENT_TAG" | tail -n 1)
git log --oneline $PREVIOUS_TAG..$CURRENT_TAG > release-notes.md
cat release-notes.md
- name: Publish Release
uses: ncipollo/release-action@v1
if: env.release_exists == 'false'
with:
artifacts: ${{ steps.package_artifact.outputs.artifacts }}
bodyFile: "release-notes.md"