-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔨 Add a workflow to auto tag when new version made
- Loading branch information
Showing
1 changed file
with
55 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,55 @@ | ||
# When Dashy's version in package.json is updated | ||
# this workflow will create a new tag | ||
# And then publish it to the repository | ||
name: 🏗️ Tag on Version Change | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- 'package.json' | ||
|
||
jobs: | ||
tag-if-version-updated: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check Out Repository 🛎️ | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set Up Python 🐍 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Extract Version from package.json 🔢 | ||
id: package_version | ||
run: | | ||
import json | ||
with open('package.json', 'r') as f: | ||
version = json.load(f)['version'] | ||
print(f"::set-output name=VERSION::{version}") | ||
shell: python | ||
|
||
- name: Get Latest Tag 🏷️ | ||
id: latest_tag | ||
run: | | ||
git fetch --tags | ||
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1` 2>/dev/null) | ||
echo "::set-output name=TAG::${latest_tag:-0}" | ||
- name: Create and Push Tag ⤴️ | ||
if: steps.package_version.outputs.VERSION != steps.latest_tag.outputs.TAG && steps.latest_tag.outputs.TAG != '0' | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "Liss-Bot" | ||
git tag -a ${{ steps.package_version.outputs.VERSION }} -m "Release v${{ steps.package_version.outputs.VERSION }}" | ||
git push origin ${{ steps.package_version.outputs.VERSION }} | ||
env: | ||
GIT_AUTHOR_NAME: Liss-Bot | ||
GIT_AUTHOR_EMAIL: [email protected] | ||
GIT_COMMITTER_NAME: Liss-Bot | ||
GIT_COMMITTER_EMAIL: [email protected] | ||
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} |