docker-ansible
docker-ansible copied to clipboard
Start using Github Releases and Improve Image Tagging Mechanism
Overview
This issue focuses on improving the versioning strategy, release management, and image tagging mechanism for the docker/ansible project. The goal is to streamline the release process, ensure compliance with standards, and provide clear versioning information to users.
Tasks
1. GitHub Releases
- Set up and document a versioning strategy (e.g., Semantic Versioning) for the project.
- Use GitHub releases to manage version tags and provide release notes.
- Update the CI/CD pipeline to trigger builds and deployments on new releases.
- Document the release process and versioning strategy in the project’s README.
2. Improve Image Tagging Mechanism
- Update the Docker meta-action to use GitHub release tags for image tagging.
- Ensure compliance with OCI Image Format Specification for tags.
- Create a script to automatically update the Docker image tags based on GitHub releases.
- Add a mechanism to deprecate old tags and inform users about deprecated versions.
Resources
Example Version Naming and Convention
| Current Version | Example Versions (Conventional) | GitHub Release |
|---|---|---|
| gableroux/ansible:1.2.3 | gableroux/ansible:1.2.3-1 | 1.0.0 |
| gableroux/ansible:1.2.3 | gableroux/ansible:1.2.3-1.0 | 1.0.0 |
| gableroux/ansible:1.2.3 | gableroux/ansible:1.2.3-1.0.0 | 1.0.0 |
| gableroux/ansible:1.2.3 | gableroux/ansible:1.2.3-1 (overwritten) | 1.0.1 (new release) |
| gableroux/ansible:1.2.3 | gableroux/ansible:1.2.3-1.0 (overwritten) | 1.0.1 (new release) |
| gableroux/ansible:1.2.3 | gableroux/ansible:1.2.3-1.0.1 (new) | 1.0.1 (new release) |
Publishing a release with 1.0.1 would overwrite gableroux/ansible:1.2.3-1 and gableroux/ansible:1.2.3-1.0, and create gableroux/ansible:1.2.3-1.0.1.
Draft of a workflow that would possibly handle this
name: Release and Publish Docker Image
on:
release:
types: [published]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from release tag
id: extract_version
run: |
VERSION="${GITHUB_REF#refs/tags/}"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
MAJOR="${VERSION%%.*}"
MINOR="${VERSION#*.}"
MINOR="${MINOR%%.*}"
PATCH="${VERSION##*.}"
echo "MAJOR=${MAJOR}" >> $GITHUB_ENV
echo "MINOR=${MINOR}" >> $GITHUB_ENV
echo "PATCH=${PATCH}" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
gableroux/ansible:${{ env.VERSION }}
gableroux/ansible:${{ env.VERSION }}-${{ env.MAJOR }}
gableroux/ansible:${{ env.VERSION }}-${{ env.MAJOR }}.${{ env.MINOR }}
gableroux/ansible:${{ env.VERSION }}-${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCH }}
labels: |
org.opencontainers.image.source=${{ github.repository }}
org.opencontainers.image.version=${{ env.VERSION }}