Skip to content

v1.3.0

v1.3.0 #6

Workflow file for this run

name: 📌 Deploy release
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag_name:
description: "Tag to release"
required: true
env:
REGISTRY: "ghcr.io"
REPO_NAME: ${{ github.event.repository.name }}
USER_NAME: "wayofdev"
USER_EMAIL: "the@wayof.dev"
jobs:
image:
runs-on: ubuntu-latest
name: Release Actions
steps:
- name: 📦 Checkout
uses: actions/checkout@v3
- name: 🔑 Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
- name: 🔨 Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: 🚀 Build action image
id: image_build
run: |
RELEASE_TAG="${{ github.event.release.tag_name }}${{ github.event.inputs.tag_name }}"
docker buildx build \
--build-arg FETCH_CHECKSUMS=yes \
--build-arg VERSION="${RELEASE_TAG:1}" \
--build-arg FROM_REGISTRY=$REGISTRY \
--build-arg FROM_REPO=${GITHUB_REPOSITORY_OWNER,,} \
--build-arg FROM_IMAGE=${REPO_NAME}-base \
--tag $REGISTRY/${GITHUB_REPOSITORY_OWNER,,}/$REPO_NAME:$RELEASE_TAG \
--platform linux/amd64,linux/arm64 \
--attest type=provenance,mode=max,builder-id=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID \
--push \
--iidfile manifest-list-digest.txt \
image
echo "digest=$(<manifest-list-digest.txt)" >> "$GITHUB_OUTPUT"
- name: Release actions
run: |
export RELEASE_TAG="${{ github.event.release.tag_name }}${{ github.event.inputs.tag_name }}"
export major=$(echo $RELEASE_TAG | cut -d. -f1)
export minor=$(echo $RELEASE_TAG | cut -d. -f2)
git config --global user.name "$USER_NAME"
git config --global user.email "$USER_EMAIL"
function prepare_release() {
rsync -r $GITHUB_WORKSPACE/$action/ $HOME/$action
rm -rf $HOME/$action/.github
mkdir $HOME/$action/.github
}
for action in $(cd $GITHUB_WORKSPACE && find . -name action.yaml -printf "%h\n" | sed 's/^.\///'); do
if git clone https://$GITHUB_ACTOR:${{ secrets.PERSONAL_GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY_OWNER/$action.git "$HOME/$action"; then
echo "Releasing $GITHUB_REPOSITORY_OWNER/$action@$RELEASE_TAG"
# git tags that use GitHub Container Registry for the image
prepare_release
sed -i "s| image:.*| image: docker://ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/$REPO_NAME@${{ steps.image_build.outputs.digest }}|" $HOME/$action/action.yaml
git -C "$HOME/$action" add -A
git -C "$HOME/$action" commit -m "$RELEASE_TAG"
git -C "$HOME/$action" tag --force -a -m"$RELEASE_TAG" "$RELEASE_TAG"
git -C "$HOME/$action" tag --force -a -m"$RELEASE_TAG" "$major"
git -C "$HOME/$action" tag --force -a -m"$RELEASE_TAG" "$major.$minor"
git -C "$HOME/$action" push --force
git -C "$HOME/$action" push --force --tags
# Create the github release
cat $GITHUB_WORKSPACE/.github/release_template.md \
| envsubst \
| jq --slurp --raw-input --arg RELEASE_TAG "$RELEASE_TAG" '{"tag_name": $RELEASE_TAG, "name": $RELEASE_TAG, "body": . }' \
| curl -X POST \
--user $GITHUB_ACTOR:${{ secrets.PERSONAL_GITHUB_TOKEN }} \
--header "Content-Type: application/json" \
--data-binary @- \
"https://api.github.com/repos/$GITHUB_REPOSITORY_OWNER/$action/releases"
else
echo "Skipping $GITHUB_REPOSITORY_OWNER/$action"
fi
done