Skip to content

Commit

Permalink
Sends release notice to the telegram channel
Browse files Browse the repository at this point in the history
  • Loading branch information
waybackarchiver committed Aug 14, 2021
1 parent dba8602 commit 79bb6c8
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 22 deletions.
86 changes: 65 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

env:
PRODUCT: screenshot

jobs:
build:
name: Build
Expand Down Expand Up @@ -63,8 +66,8 @@ jobs:
- name: Upload archived binary
uses: actions/upload-artifact@v2
with:
name: screenshot
path: build/package/screenshot*
name: ${{ env.PRODUCT }}
path: build/package/${{ env.PRODUCT }}*

checksum:
name: Get archived packages checksum
Expand All @@ -76,7 +79,7 @@ jobs:
- name: Download math result from build job
uses: actions/download-artifact@v2
with:
name: screenshot
name: ${{ env.PRODUCT }}
path: .

- name: Create all binary digest
Expand All @@ -92,31 +95,72 @@ jobs:
runs-on: ubuntu-latest
needs: [build, checksum]
steps:
- name: Check out code base
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Download math result from build and checksum jobs
uses: actions/download-artifact@v2
with:
name: screenshot
path: screenshot
name: ${{ env.PRODUCT }}
path: ${{ env.PRODUCT }}

- name: Generate Git log
run: |
git fetch origin +refs/tags/*:refs/tags/*
echo "Current Tag: ${GITHUB_REF}"
git checkout ${GITHUB_REF} -b release-log
GITVER=$(git describe --tags)
PREVVER=$(git describe --tags --abbrev=0 ${GITVER}~1)
git log --oneline ${PREVVER}..${GITVER} > gittaglogs.txt
MORE=$(echo "See more on [releases](https://github.com/${{ github.repository }}/releases)")
echo -e "*Release ${GITVER}* #screenshot\n" > release-note.md
cut -c9- gittaglogs.txt | sed -e 's/^/- /' | sed -e 's/\"/\\"/g' >> release-note.md
echo -e "\n${MORE}" | tee -a release-note.md gittaglogs.txt > /dev/null
# Append digests
echo '
**Digests in this release:**
```
${{ needs.checksum.outputs.digest }}
```
' >> gittaglogs.txt
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: release-note
path: release-note.md

- name: Create Release
uses: actions/create-release@v1
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
**Digests in this release:**
```
${{ needs.checksum.outputs.digest }}
```
draft: false
body_path: gittaglogs.txt
files: ${{ env.PRODUCT }}/*${{ env.PRODUCT }}*
prerelease: true
draft: false

- name: Upload release assets
uses: fnkr/github-action-ghr@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GHR_PATH: screenshot/
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
notification:
name: Send Notification
runs-on: ubuntu-latest
needs: [release]
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: release-note
path: .

- name: Send release note to Telegram channel
continue-on-error: true
run: |
TEXT="$(cat release-note.md)"
echo -e "${TEXT}"
curl --silent --output /dev/null --show-error --fail -X POST \
-H 'Content-Type: application/json' \
-d '{"chat_id": "${{ secrets.TELEGRAM_TO }}", "text": "'"${TEXT}"'", "parse_mode": "markdown"}' \
"https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage"
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Mark stale issues and pull requests
uses: actions/stale@v3
uses: actions/stale@v4
with:
repo-token: ${{ github.token }}
stale-issue-message: "This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 5 days"
Expand Down

0 comments on commit 79bb6c8

Please sign in to comment.