add tagging #2
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
name: CI | |
on: | |
push: | |
paths: | |
- '.github/workflows/**' | |
schedule: | |
- cron: '0 0 1 * *' | |
workflow_dispatch: | |
jobs: | |
update-database: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: update database | |
env: | |
MAXMIND_LICENSE_KEY: ${{ secrets.MAXMIND_LICENSE_KEY }} | |
run: | | |
git config user.name maxmind-updater | |
git config user.email maxmind-updater@github-actions | |
echo "Downloading .tar.gz with database." | |
curl -o geoLite2City.tar.gz --url "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=$MAXMIND_LICENSE_KEY&suffix=tar.gz" || exit 1 | |
echo "Untaring database" | |
tar -xzvf geoLite2City.tar.gz || exit 1 | |
echo "Removing archive" | |
rm -f geoLite2City.tar.gz | |
geoLite2CityDir="$(ls | grep "GeoLite2-City_" | head -n 1)" | |
if [ -z "$geoLite2CityDir" ]; then exit 1; fi | |
mv -f "$geoLite2CityDir/GeoLite2-City.mmdb" src/GeoLite2-City.mmdb || exit 1 | |
rm -rf "./$geoLite2CityDir" | |
git add GeoLite2-City.mmdb || exit 1 | |
if ! git diff-index --quiet HEAD; then | |
git commit -m "update GeoLite2-City.mmdb" || exit 1 | |
git push || exit 1 | |
fi | |
- name: create tag | |
run: | | |
latestVersion="$(git describe --tags $(git rev-list --tags --max-count=1)" | |
latestVersionPrefix="$(awk -F'.' '{ $NF=""; print }' <<< "$latestVersion" | tr " " ".")" | |
latestMinorVersion="$(sed "s/$latestVersionPrefix//g" <<< "$latestVersion")" | |
newMinorVersion=$(( $latestMinorVersion + 1 )) | |
newVersion="$latestVersionPrefix$newMinorVersion" | |
git tag "$newVersion" | |
git push origin "$newVersion" || exit 1 |