Skip to content

Merge pull request #1280 from spidernet-io/fix/policy #33

Merge pull request #1280 from spidernet-io/fix/policy

Merge pull request #1280 from spidernet-io/fix/policy #33

Workflow file for this run

name: Auto Release Version
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
workflow_dispatch:
inputs:
tag:
description: 'Tag'
required: true
default: v1.0.0
permissions: write-all
jobs:
get-tag:
runs-on: ubuntu-latest
outputs:
tag: ${{ env.RUN_TAG }}
steps:
- name: Get Ref
id: get_ref
run: |
if ${{ github.event_name == 'workflow_dispatch' }} ; then
echo "call by self workflow_dispatch"
echo "RUN_TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
YBranchName=` grep -Eo "v[0-9]+\.[0-9]+" <<< "${{ github.event.inputs.tag }}" `
elif ${{ github.event_name == 'push' }} ; then
echo "call by push tag"
echo "RUN_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
YBranchName=` grep -Eo "v[0-9]+\.[0-9]+" <<< "${GITHUB_REF##*/}" `
else
echo "unexpected event: ${{ github.event_name }}"
exit 1
fi
echo "YBranchName=${YBranchName}"
if [ -n "$YBranchName" ] ; then
echo "RUN_YBranchName=${YBranchName}" >> $GITHUB_ENV
else
echo "error, failed to find y branch"
exit 1
fi
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ env.RUN_TAG }}
- name: Check Version
run: |
TagVersion="${{ env.RUN_TAG }}"
RecordVersion=` cat VERSION | tr -d ' ' | tr -d '\n' `
if [ "$RecordVersion" != "$TagVersion" ] ; then
echo "error, version $RecordVersion of '/VERSION' is different with Tag $TagVersion "
exit 1
fi
#no need to check chart version, which will auto update to /VERSION by CI
#- name: release Z branch
# uses: peterjgrainger/action-create-branch@v2.4.0
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# branch: 'release-${{ env.RUN_TAG }}'
# sha: '${{ github.sha }}'
# if branch exists, the action will no fail, and it output created=false
- name: release Y branch
uses: peterjgrainger/action-create-branch@v2.4.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: 'release-${{ env.RUN_YBranchName }}'
sha: '${{ github.sha }}'
# for auto-cherrypick.yaml, create a label
- name: Create cherry-pick label
continue-on-error: true
run: |
echo ${{ secrets.WELAN_PAT }} | gh auth login --with-token
branchLabelName="${{ env.LABEL_PREFIX_CHERRYPICK }}release-${{ env.RUN_YBranchName }}"
mainLabelName="${{ env.LABEL_PREFIX_CHERRYPICK }}main"
echo "try to create label "
gh label create ${branchLabelName} --force ; if [ $? -ne 0 ]; then echo -e "\e[31merror, failed to create label ${branchLabelName}\e[0m"; fi
gh label create ${mainLabelName} --force ; if [ $? -ne 0 ]; then echo -e "\e[31merror, failed to create label ${mainLabelName}\e[0m"; fi
build-release-image:
needs: get-tag
uses: ./.github/workflows/build-image-release.yaml
with:
ref: ${{ needs.get-tag.outputs.tag }}
secrets: inherit
release-changelog:
needs: [build-release-image, get-tag]
uses: ./.github/workflows/call-release-changelog.yaml
with:
dest_tag: ${{ needs.get-tag.outputs.tag }}
secrets: inherit
release-pages:
needs: [build-release-image, get-tag]
uses: ./.github/workflows/call-release-pages.yaml
with:
ref: ${{ needs.get-tag.outputs.tag }}
secrets: inherit
release-chart:
needs: [build-release-image, get-tag]
uses: ./.github/workflows/call-release-chart.yaml
with:
ref: ${{ needs.get-tag.outputs.tag }}
secrets: inherit
create-release:
needs: [release-changelog, get-tag, release-chart]
name: create release
runs-on: ubuntu-latest
steps:
- name: Download Chart Artifact
uses: actions/download-artifact@v3.0.2
with:
name: ${{ needs.release-chart.outputs.artifact }}
path: chart-package/
- name: Download Changelog Artifact
uses: actions/download-artifact@v3.0.2
with:
name: ${{ needs.release-changelog.outputs.artifact }}
path: changelog-result/
- name: Get Downloaded Files
id: download_file
run: |
# ========= chart
if ! ls chart-package/*.tgz &>/dev/null ; then
echo "error, failed to find any chart "
exit 1
fi
chart_path=$( ls chart-package/*.tgz )
echo "RUN_CHART_PATH=${chart_path}" >> $GITHUB_ENV
# ========== changelog
if ! ls changelog-result/*.md &>/dev/null ; then
echo "error, failed to find changelog "
exit 2
fi
ls changelog-result/
cat changelog-result/*.md
changelog_file=$( ls changelog-result/ )
changelog_path=./changelog-result/${changelog_file}
echo "RUN_CHANGELOG_PATH=${changelog_path}" >> $GITHUB_ENV
cp ./changelog-result/${changelog_file} ./changelog-result/changelog.md
- name: Create Release
id: create_release
continue-on-error: false
uses: ncipollo/release-action@v1.14.0
with:
artifacts: "chart-package/*"
allowUpdates: true
removeArtifacts: true
replacesArtifacts: true
artifactErrorsFailBuild: true
bodyFile: "./changelog-result/changelog.md"
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.get-tag.outputs.tag }}
name: "Release ${{ needs.get-tag.outputs.tag }}"