-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5e03cc
commit 57dc95e
Showing
1 changed file
with
116 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
name: Tag Version and Publish on Push to Master | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
tag_version_and_publish: | ||
|
||
runs-on: self-hosted | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Read version from pubspec.yml | ||
id: read_version | ||
run: | | ||
VERSION=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2) | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
- name: Create tag | ||
id: create_tag | ||
run: | | ||
# Checks if the tag already exists in the remote repository | ||
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then | ||
echo "Error: Tag v${{ env.VERSION }} already exists." | ||
exit 1 | ||
fi | ||
# Check if the version was found | ||
if [ -z "${{ env.VERSION }}" ]; then | ||
echo "Error: No version found in pubspec.yml" | ||
exit 1 | ||
fi | ||
git tag "v${{ env.VERSION }}" | ||
git push origin "v${{ env.VERSION }}" | ||
- name: Handle job completion | ||
if: always() | ||
run: | | ||
if [ "${{ job.status }}" == "failure" ]; then | ||
landa-messenger-api chat-send \ | ||
--id "${{ secrets.CHAT_ID }}" \ | ||
--api_key "${{ secrets.CHAT_KEY }}" \ | ||
--title "🔴 Creation Tag Failed" \ | ||
--body "${{ github.repository }}: Tag v${{ env.VERSION }}" \ | ||
--url "https://github.com/landamessenger/catalog/actions/workflows/tag_version_and_publish.yml" \ | ||
--image "https://avatars.githubusercontent.com/u/63705403?s=200&v=4" \ | ||
--background_color "#55000000" \ | ||
--text_color "#FFFFFFFF" | ||
elif [ "${{ job.status }}" == "cancelled" ]; then | ||
landa-messenger-api chat-send \ | ||
--id "${{ secrets.CHAT_ID }}" \ | ||
--api_key "${{ secrets.CHAT_KEY }}" \ | ||
--title "🟠 Creation Tag Canceled" \ | ||
--body "${{ github.repository }}: Tag v${{ env.VERSION }}" \ | ||
--url "https://github.com/landamessenger/catalog/actions/workflows/tag_version_and_publish.yml" \ | ||
--image "https://avatars.githubusercontent.com/u/63705403?s=200&v=4" \ | ||
--background_color "#55000000" \ | ||
--text_color "#FFFFFFFF" | ||
else | ||
landa-messenger-api chat-send \ | ||
--id "${{ secrets.CHAT_ID }}" \ | ||
--api_key "${{ secrets.CHAT_KEY }}" \ | ||
--title "🟢 Creation Tag Passed" \ | ||
--body "${{ github.repository }}: Tag v${{ env.VERSION }}" \ | ||
--url "https://github.com/landamessenger/catalog/actions/workflows/tag_version_and_publish.yml" \ | ||
--image "https://avatars.githubusercontent.com/u/63705403?s=200&v=4" \ | ||
--background_color "#55000000" \ | ||
--text_color "#FFFFFFFF" | ||
fi | ||
- run: flutter pub get | ||
|
||
- run: dart pub publish --dry-run | ||
|
||
- run: dart pub publish -f | ||
|
||
- name: Handle publish job completion | ||
if: always() | ||
run: | | ||
if [ "${{ job.status }}" == "failure" ]; then | ||
landa-messenger-api chat-send \ | ||
--id "${{ secrets.CHAT_ID }}" \ | ||
--api_key "${{ secrets.CHAT_KEY }}" \ | ||
--title "🔴 Pub Publish Failed" \ | ||
--body "${{ github.repository }}: ${{ github.event.head_commit.message }}" \ | ||
--url "https://github.com/landamessenger/catalog/actions/workflows/tag_version_and_publish.yml" \ | ||
--image "https://avatars.githubusercontent.com/u/63705403?s=200&v=4" \ | ||
--background_color "#55000000" \ | ||
--text_color "#FFFFFFFF" | ||
elif [ "${{ job.status }}" == "cancelled" ]; then | ||
landa-messenger-api chat-send \ | ||
--id "${{ secrets.CHAT_ID }}" \ | ||
--api_key "${{ secrets.CHAT_KEY }}" \ | ||
--title "🟠 Pub Publish Canceled" \ | ||
--body "${{ github.repository }}: ${{ github.event.head_commit.message }}" \ | ||
--url "https://github.com/landamessenger/catalog/actions/workflows/tag_version_and_publish.yml" \ | ||
--image "https://avatars.githubusercontent.com/u/63705403?s=200&v=4" \ | ||
--background_color "#55000000" \ | ||
--text_color "#FFFFFFFF" | ||
else | ||
landa-messenger-api chat-send \ | ||
--id "${{ secrets.CHAT_ID }}" \ | ||
--api_key "${{ secrets.CHAT_KEY }}" \ | ||
--title "🟢 Pub Publish Passed" \ | ||
--body "${{ github.repository }}: ${{ github.event.head_commit.message }}" \ | ||
--url "https://github.com/landamessenger/catalog/actions/workflows/tag_version_and_publish.yml" \ | ||
--image "https://avatars.githubusercontent.com/u/63705403?s=200&v=4" \ | ||
--background_color "#55000000" \ | ||
--text_color "#FFFFFFFF" | ||
fi | ||
|