Sir Athos helped me (thank you very much) today today on a separate issue that helped me a lot.
I am now stuck at the point where I want to change a simple text file and include it in my push. So basically I want to add the changed text file to the commit and push it as a commit with this tag the build number as release. Hope I feel here.
My code to do this so far,
#!/bin/bash
YEAR=$(date +"%Y")
MONTH=$(date +"%m")
git config --global user.email "${GIT_EMAIL}"
git config --global user.name "${GIT_NAME}"
git config --global push.default simple
export GIT_TAG=v2.$YEAR-$MONTH.$TRAVIS_BUILD_NUMBER
git fetch --tags
msg="Tag Generated from TravisCI for build $TRAVIS_BUILD_NUMBER"
echo "$msg" >> $TRAVIS_BUILD_DIR/build.txt
git add -A
if git tag $GIT_TAG -a -m "$msg" 2>/dev/null; then
git tag $GIT_TAG -a -m "Tag Generated from TravisCI for build $TRAVIS_BUILD_NUMBER"
git push https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG} HEAD:master && git push https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG} --tags HEAD:master
ls -aR
else echo Tag already exists!; fi
The if ... else ... code given to me by Sir Athos earlier works 100% if it exists, if the tag exists, and then either clicking if it does not exist or not clicking it, it exists.
I was just stuck and now Travis has included a simple build.txt file that I pass to $ TRAVIS_BUILD_DIR with the addition.
, travis.yml :
file:
- build.txt
Travis build.txt , . , - , , .
:
bash script , if. build.txt . Travis untagged-cc6ebe6dbcbb13bc599c, , , . , , , .
YEAR=$(date +"%Y")
MONTH=$(date +"%m")
git config --global user.email "${GIT_EMAIL}"
git config --global user.name "${GIT_NAME}"
git config --global push.default simple
export GIT_TAG=v2.$YEAR-$MONTH.$TRAVIS_BUILD_NUMBER
git fetch --tags
msg="Tag Generated from TravisCI for build $TRAVIS_BUILD_NUMBER"
if git tag $GIT_TAG -a -m "$msg" 2>/dev/null; then
echo "$msg" >> $TRAVIS_BUILD_DIR/build.txt
git add $TRAVIS_BUILD_DIR/build.txt
git commit -m "Update build version file with $TRAVIS_BUILD_NUMBER"
$TRAVIS_BUILD_NUMBER"
git push https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG} HEAD:master && git push https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG} --tags HEAD:master
ls -aR
else echo Tag already exists!; fi
, travis.yml before_deploy, . , , -. , .