Daily CI #347
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: Daily CI | |
on: | |
schedule: | |
- cron: '30 14 * * *' | |
jobs: | |
new-tag: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Delete old tags and releases | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const {data: releases} = await github.rest.repos.listReleases({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
}); | |
for (const release of releases) { | |
console.log(`Deleting release ${release.tag_name}`); | |
await github.rest.repos.deleteRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: release.id, | |
}); | |
console.log(`Deleting tag ${release.tag_name}`); | |
await github.rest.git.deleteRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: `tags/${release.tag_name}`, | |
}); | |
} | |
- name: Set tag | |
run: | | |
DAILY_TAG=$(date +'%Y-%m-%d') | |
echo "DAILY_TAG=$DAILY_TAG" >> $GITHUB_ENV | |
- name: Create Tag | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const {DAILY_TAG} = process.env | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: `refs/tags/${DAILY_TAG}`, | |
sha: context.sha | |
}) | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
- name: Build geoip.dat | |
run: | | |
go run ./ -c config-ir.json | |
- name: Move files to publish directory | |
run: | | |
mkdir publish | |
mv output/dat/*.dat publish | |
mv output/text/*.txt publish | |
- name: Publish release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ env.DAILY_TAG }} | |
name: ${{ env.DAILY_TAG }} | |
prerelease: false | |
draft: false | |
files: "publish/*" |