Auto Taginator 9000 #578
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@v7 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Set up Docker | |
| uses: docker/setup-docker-action@v5 | |
| with: | |
| daemon-config: | | |
| { | |
| "debug": true, | |
| "features": { | |
| "containerd-snapshotter": true | |
| } | |
| } | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v4 | |
| - name: Calculate New Tag | |
| id: calculatenewtag | |
| shell: pwsh | |
| run: | | |
| Set-Location -Path "/home/runner/work/MultiNet/MultiNet/" | |
| $symVerTags = @() | |
| $describedTags = git tag | Sort-Object -Descending | |
| foreach($tag in $describedTags) | |
| { | |
| $symVerTags += [System.Version]::Parse($tag) | |
| } | |
| $versionParsed = $symVerTags | Sort-Object -Descending | Select-Object -First 1 | |
| $newTagVersion = [System.Version]::new($versionParsed.Major, $versionParsed.Minor, $versionParsed.Build + 1) | |
| $newTagVersionString = $newTagVersion.ToString() | |
| Write-Host "New Tag: $($newTagVersionString)" | |
| Write-Output "tag=$($newTagVersionString)" >> $env:GITHUB_OUTPUT | |
| - 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 --platform linux/amd64,linux/arm64 -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@v4 | |
| with: | |
| username: felsokning | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Publish to DockerHub | |
| run: docker push --all-tags felsokning/multinet | |
| # Only publish tag after the release has been created and pushed successfully to DockerHub, otherwise the release will be created but the tag will not be available in DockerHub. | |
| - 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 |