Auto Taginator 9000 #24
This file contains hidden or 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: Auto Taginator 9000 | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: 0 0 * * * | |
| jobs: | |
| create_release: | |
| name: Create Release Tag | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@main | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Calculate New Tag | |
| id: calculatenewtag | |
| shell: pwsh | |
| run: | | |
| Set-Location -Path "/home/runner/work/MultiNet/MultiNet/" | |
| $describedTag = git tag | Sort-Object -Descending | Select-Object -First 1 | |
| # Need to hunt if it's a tag + commits or just tag | |
| $versionString = [string]::Empty | |
| if ($describedTag.Contains("-")) | |
| { | |
| $versionString = $describedTag.Substring(0, $describedTag.IndexOf("-")) | |
| } | |
| else | |
| { | |
| $versionString = $describedTag.ToString() | |
| } | |
| $versionParsed = [System.Version]::Parse($versionString) | |
| $newTagVersion = [System.Version]::new($versionParsed.Major, $versionParsed.Minor, $versionParsed.Build + 1) | |
| $newTagVersionString = $newTagVersion.ToString() | |
| Write-Output "tag=$($newTagVersionString)" >> $env:GITHUB_OUTPUT | |
| - name: Create Tag Release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| tag: ${{ steps.calculatenewtag.outputs.tag }} | |
| run: | | |
| gh release create "$tag" --repo="$GITHUB_REPOSITORY" --title="${GITHUB_REPOSITORY#*/} ${tag#v}" --generate-notes | |
| - name: "Set current date as env variable" | |
| run: | | |
| echo "builddate=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT | |
| id: dateversion | |
| - name: Build Docker Image | |
| run: docker build -t felsokning/multinet:${{ github.sha }} . | |
| - name: Tag Docker Image (Git Tag) | |
| run: docker tag felsokning/multinet:${{ github.sha }} felsokning/multinet:${{ steps.calculatenewtag.outputs.tag }} | |
| - name: Tag Docker Image (Date) | |
| run: docker tag felsokning/multinet:${{ github.sha }} felsokning/multinet:${{ steps.dateversion.outputs.builddate }} | |
| - name: Tag Docker Image (latest) | |
| run: docker tag felsokning/multinet:${{ github.sha }} felsokning/multinet:latest | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: felsokning | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Publish to DockerHub | |
| run: docker push --all-tags felsokning/multinet |