Skip to content

Build and Publish

Build and Publish #5

name: Build and Publish
on:
push:
tags:
- 'v*'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build_and_push_image:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Set Environment Variables and tags
run: |
REPOSITORY=$(echo '${{ github.repository }}' |awk -F '/' '{gsub(/-/, "_", $0) ;print $NF}')
TAG=$(echo ${{github.ref_name}})
echo "TAG=$TAG" >> $GITHUB_ENV
- name: Checkout current repo
uses: actions/checkout@v4
- name: Set package version
run: sed -E -i "s/^__version__ = \"[a-z0-9\.]+\"/__version__ = \"$VERSION\"/g" ${REPOSITORY}/hashcat_wrapper.py
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}