Normalize repository name in README to lowercase #55
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: Build Docker image and Create Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
get-version: | |
runs-on: ubuntu-24.04 | |
outputs: | |
version: ${{ steps.get_version.outputs.version }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Get Version from Cargo.toml | |
id: get_version | |
run: | | |
version=$(awk -F ' = ' '/^version/ {print $2}' Cargo.toml | tr -d '"') | |
echo "Version from Cargo.toml: $version" | |
echo "version=$version" >> $GITHUB_OUTPUT | |
build: | |
needs: get-version | |
runs-on: ubuntu-24.04 | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
install: true | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ github.repository_owner }}/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') | |
tags: | | |
latest, | |
${{ needs.get-version.outputs.version }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: $(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]'):latest,$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]'):${{ needs.get-version.outputs.version }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
create-release: | |
needs: [get-version, build] | |
runs-on: ubuntu-24.04 | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up GitHub CLI | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 22 | |
- name: Create Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
version="${{ needs.get-version.outputs.version }}" | |
if ! gh release create "$version" \ | |
--repo="$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" \ | |
--title="$version" \ | |
--generate-notes; then | |
if gh release view "$version" --repo $(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') &>/dev/null; then | |
echo "Release $version already exists, treating as success" | |
exit 0 | |
else | |
echo "Failed to create release and release doesn't exist" | |
exit 1 | |
fi | |
fi |