Skip to content

chore(deps): bump github.com/schollz/progressbar/v3 in the gomod grou… #56

chore(deps): bump github.com/schollz/progressbar/v3 in the gomod grou…

chore(deps): bump github.com/schollz/progressbar/v3 in the gomod grou… #56

Workflow file for this run

name: Release
on:
push:
branches: master
tags:
- '*'
paths:
- '.github/workflows/release.yml'
- 'go.mod'
- 'pkg/*'
- 'cmd/automatedgo/*'
jobs:
release:
name: Release
runs-on: ubuntu-latest
if: |
github.actor != 'dependabot[bot]' &&
github.actor != 'github-actions[bot]' &&
github.actor != 'protected-auto-commits[bot]'
permissions:
contents: write
packages: write
id-token: write
steps:
- name: GitHub App Token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.23.x"
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install Cosign
if: github.event_name != 'pull_request'
uses: sigstore/[email protected]
with:
cosign-release: 'v2.4.0'
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Semantic Release
uses: go-semantic-release/action@v1
id: semantic
with:
github-token: ${{ steps.app-token.outputs.token }}
- name: GoReleaser
uses: goreleaser/goreleaser-action@v6
if: steps.semantic.outputs.version != ''
with:
distribution: goreleaser
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }}
GORELEASER_CURRENT_TAG: ${{ needs.semantic.outputs.version }}
- name: Update pkg.go.dev
if: steps.semantic.outputs.version != ''
run: |
go list -m github.com/Nicconike/AutomatedGo/v2@v${{ steps.semantic.outputs.version }}
cleanup:
runs-on: ubuntu-latest
name: Cleanup
needs: release
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Delete Old Docker Hub Tags
run: |
echo "Fetching Docker Hub tags..."
tags=$(curl -s -H "Authorization: Bearer ${{ secrets.DOCKER_TOKEN }}" "https://hub.docker.com/v2/repositories/${{ vars.DOCKER_USERNAME }}/automatedgo/tags" | jq -r '.results[].name')
echo "Tags found in Docker Hub:"
echo "$tags"
latest_tag=$(echo "$tags" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -rV | head -n 1)
echo "Latest semantic version tag is $latest_tag"
for tag in $tags; do
if [[ "$tag" != "master" && "$tag" != "$latest_tag" ]]; then
echo "Deleting tag $tag from Docker Hub"
curl -X DELETE -H "Authorization: Bearer ${{ secrets.DOCKER_TOKEN }}" "https://hub.docker.com/v2/repositories/${{ vars.DOCKER_USERNAME }}/automatedgo/tags/$tag/"
else
echo "Keeping tag $tag"
fi
done
- name: Delete Old GHCR Tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO_OWNER: ${{ github.repository_owner }}
PACKAGE_NAME: "AutomatedGo"
run: |
echo "Fetching GHCR tags..."
page=1
all_tags=""
while true; do
tags=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
"https://api.github.com/user/packages/container/$PACKAGE_NAME/versions?per_page=100&page=$page" | jq -r '.[].metadata.container.tags[]')
if [ -z "$tags" ]; then
break
fi
all_tags="$all_tags $tags"
((page++))
done
echo "Tags found in GHCR:"
echo "$all_tags"
latest_tag=$(echo "$all_tags" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -rV | head -n 1)
echo "Latest semantic version tag is $latest_tag"
for tag in $all_tags; do
if [[ "$tag" != "master" && "$tag" != "$latest_tag" ]]; then
echo "Deleting tag $tag from GHCR"
version_id=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
"https://api.github.com/user/packages/container/$PACKAGE_NAME/versions" | \
jq -r ".[] | select(.metadata.container.tags[] == \"$tag\") | .id")
if [ -n "$version_id" ]; then
curl -X DELETE -H "Authorization: Bearer $GITHUB_TOKEN" \
"https://api.github.com/user/packages/container/$PACKAGE_NAME/versions/$version_id"
else
echo "Warning: Could not find version ID for tag $tag"
fi
else
echo "Keeping tag $tag"
fi
done