Hasan Iqbal
commited on
Commit
•
b98ce8c
1
Parent(s):
d005a31
Added CI/CD for HF
Browse files- .github/workflows/main.yaml +21 -0
- scripts/release.sh +111 -0
.github/workflows/main.yaml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: CI/CD
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
tags: ["v[0-9].[0-9]+.[0-9]+"]
|
6 |
+
branches: ["*"]
|
7 |
+
|
8 |
+
jobs:
|
9 |
+
huggingface_deploy:
|
10 |
+
name: Deploy to Hugging Face
|
11 |
+
runs-on: ubuntu-latest
|
12 |
+
if: ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }}
|
13 |
+
steps:
|
14 |
+
- uses: actions/checkout@v3
|
15 |
+
with:
|
16 |
+
fetch-depth: 0
|
17 |
+
lfs: true
|
18 |
+
- name: Push to Hugging Face
|
19 |
+
env:
|
20 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
21 |
+
run: git push https://hasaniqbal777:[email protected]/spaces/hasaniqbal777/OpenFactCheck main
|
scripts/release.sh
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
source "${BASH_SOURCE%/*}/common.sh"
|
4 |
+
|
5 |
+
. "$(git --exec-path)/git-sh-setup"
|
6 |
+
|
7 |
+
if [ -z "$1" ] ; then
|
8 |
+
c_echo $RED "Need to provide the version ie v0.0.0 as the first argument"
|
9 |
+
exit 1
|
10 |
+
fi
|
11 |
+
|
12 |
+
# Confirmation message, take two arguments
|
13 |
+
confirmation()
|
14 |
+
{
|
15 |
+
c_echo $YELLOW "
|
16 |
+
--------------------------------------------------------------------------------
|
17 |
+
-- Confirmation --
|
18 |
+
--------------------------------------------------------------------------------
|
19 |
+
"
|
20 |
+
c_echo $YELLOW "You are about to release the following..."
|
21 |
+
echo
|
22 |
+
c_echo $YELLOW "$1"
|
23 |
+
c_echo $YELLOW "Are you sure you want to continue? (Default: y)"
|
24 |
+
read -r CONFIRMATION
|
25 |
+
if [[ -z $CONFIRMATION ]]; then
|
26 |
+
CONFIRMATION="y"
|
27 |
+
fi
|
28 |
+
if [[ $CONFIRMATION != "y" ]]; then
|
29 |
+
c_echo $RED "Exiting..."
|
30 |
+
exit 1
|
31 |
+
fi
|
32 |
+
}
|
33 |
+
|
34 |
+
VERSION=$1
|
35 |
+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
36 |
+
|
37 |
+
# Require valid format for version
|
38 |
+
rx='^v[0-9]+\.[0-9]+\.[0-9]+$'
|
39 |
+
if ! [[ $VERSION =~ $rx ]]; then
|
40 |
+
c_echo $RED "The version must be in the format 'vX.X.X'"
|
41 |
+
exit 1
|
42 |
+
fi
|
43 |
+
|
44 |
+
# Require main branch for release
|
45 |
+
if [ "$BRANCH" != "main" ]
|
46 |
+
then
|
47 |
+
c_echo $RED "You must release on the main branch"
|
48 |
+
exit 1
|
49 |
+
fi
|
50 |
+
|
51 |
+
# make sure you have the most recent from remote main
|
52 |
+
git fetch
|
53 |
+
git pull origin main
|
54 |
+
|
55 |
+
if [ x"$(git rev-parse $BRANCH)" != x"$(git rev-parse origin/$BRANCH)" ]
|
56 |
+
then
|
57 |
+
c_echo $RED "Out of sync with remote"
|
58 |
+
git status
|
59 |
+
exit 1
|
60 |
+
fi
|
61 |
+
|
62 |
+
# Require no untracked files
|
63 |
+
if [[ -n $(git status -s) ]]
|
64 |
+
then
|
65 |
+
c_echo $RED "Untracked files detected. Please stash or commit"
|
66 |
+
git status -s
|
67 |
+
exit 1
|
68 |
+
fi
|
69 |
+
|
70 |
+
# Require new tag/version
|
71 |
+
if [ $(git tag -l "$VERSION") ]; then
|
72 |
+
c_echo $RED "The tag/version already exists..."
|
73 |
+
echo
|
74 |
+
echo Tags:
|
75 |
+
git tag
|
76 |
+
exit 1
|
77 |
+
fi
|
78 |
+
|
79 |
+
# Require clean working tree for release
|
80 |
+
require_clean_work_tree release "Please commit or stash them and sync with remote"
|
81 |
+
|
82 |
+
# Get most recent tag
|
83 |
+
PREVIOUS_TAG=$(git describe --tags --abbrev=0)
|
84 |
+
|
85 |
+
# Build commit message for version bump
|
86 |
+
MESSAGE="Release: $VERSION
|
87 |
+
|
88 |
+
Changes:
|
89 |
+
|
90 |
+
$(git log --pretty=oneline $PREVIOUS_TAG..)
|
91 |
+
|
92 |
+
Diff:
|
93 |
+
|
94 |
+
https://github.com/hasaniqbal777/$APP_NAME/compare/$PREVIOUS_TAG...$VERSION
|
95 |
+
"
|
96 |
+
|
97 |
+
# Confirmation message
|
98 |
+
confirmation "$MESSAGE"
|
99 |
+
|
100 |
+
c_echo $GREEN "Releasing Version $VERSION"
|
101 |
+
echo
|
102 |
+
|
103 |
+
# Modify the VERSION file
|
104 |
+
printf "$VERSION" > ./VERSION
|
105 |
+
git add ./VERSION
|
106 |
+
git commit -m "🚀 $MESSAGE"
|
107 |
+
git tag $VERSION
|
108 |
+
git push origin $BRANCH
|
109 |
+
git push origin $VERSION
|
110 |
+
|
111 |
+
gh release create $VERSION --generate-notes
|