release #33
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
name: release | |
on: | |
workflow_dispatch: | |
ref: main | |
branches: | |
- main | |
permissions: | |
teams: | |
- development | |
jobs: | |
release: | |
name: Release on GitHub | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: write | |
pages: write | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Restore binaries from cache | |
uses: actions/cache/restore@v4 | |
with: | |
path: ./bin | |
key: binary | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
check-latest: true | |
cache: true | |
- name: Setup node caches | |
uses: actions/cache@v4 | |
with: | |
path: | | |
${{ github.workspace }}/.cache | |
key: ${{ runner.os }}-yarn-${{ hashFiles('package.json') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Import GPG key | |
uses: crazy-max/ghaction-import-gpg@v6 | |
with: | |
gpg_private_key: ${{ secrets.VM_BOT_GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.VM_BOT_PASSPHRASE }} | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
- name: Prepare release notes if tag not exists | |
env: | |
GRAFANA_ACCESS_POLICY_TOKEN: ${{ secrets.GRAFANA_ACCESS_POLICY_TOKEN }} | |
run: | | |
export PKG_TAG="v$(yq -r '.version' package.json)" | |
if git show-ref --tags --verify --quiet "refs/tags/${TAG}"; then | |
echo "Tag ${PKG_TAG} exists, skipping release" | |
else | |
echo "PKG_TAG=$PKG_TAG" >> $GITHUB_ENV | |
echo "Tag ${PKG_TAG} does not exist, pushing a new one" | |
if ! grep -q "^## tip$" CHANGELOG.md; then | |
echo "ERROR: Not found 'tip' section in CHANGELOG. Please add relavant entries and recreate git tag" | |
exit 1 | |
fi | |
sed -n '/## tip/,/## /p' CHANGELOG.md | sed -e '$d' -e '1d' > NOTES.md | |
sed -i 's/## tip/&\n\n## '${PKG_TAG}'/' CHANGELOG.md | |
make vl-plugin-check | |
git tag ${TAG} | |
git push origin ${TAG} | |
fi | |
- name: Prapare binary cache | |
if: ${{ hashFiles('NOTES.md') != '' }} | |
uses: actions/cache@v4 | |
with: | |
path: ./bin | |
key: binary | |
- name: Upload release assets | |
if: ${{ hashFiles('NOTES.md') != '' }} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release create ${{ env.PKG_TAG }} \ | |
--title=${{ env.PKG_TAG }} \ | |
--notes-file=NOTES.md ./dist/* | |
- name: Automatic changelog update | |
if: ${{ hashFiles('NOTES.md') != '' }} | |
run: | | |
rm -rf NOTES.md | |
export CL_BRANCH="changelog-update-$(date +%s)" | |
git checkout -b "${CL_BRANCH}" | |
git add CHANGELOG.md | |
git commit -S -m "Automatic CHANGELOG update" | |
git push origin ${CL_BRANCH} | |
gh pr create \ | |
-H $(git branch --show-current) \ | |
-t "Automatic CHANGELOG update" \ | |
-b "Automatic CHANGELOG update" | |
env: | |
GH_TOKEN: "${{ secrets.VM_BOT_GH_TOKEN }}" | |
GITHUB_TOKEN: "${{ secrets.VM_BOT_GH_TOKEN }}" |