Merge pull request #17 from mogenius/develop #153
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: MAIN | |
on: | |
push: | |
branches: | |
- main | |
repository_dispatch: | |
types: [build-from-punq-frontend] | |
env: | |
IMAGE_NAME: ghcr.io/mogenius/punq | |
DOCKERFILE: Dockerfile-Operator | |
VERSION: | |
HOME: /root | |
jobs: | |
prepare: | |
runs-on: [self-hosted, X64] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Create Sematic Release Version | |
shell: bash -ieo pipefail {0} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --system http.sslVerify false | |
git config --global user.email "[email protected]" | |
git config --global user.name "punq" | |
git config --global credential.helper cache | |
semantic-release | |
VERSION=$(git describe --tags $(git rev-list --tags --max-count=1)) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
COMMIT_HASH=$(git rev-parse --short HEAD) | |
echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_ENV | |
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV | |
BUILD_TIMESTAMP=$(date) | |
echo "BUILD_TIMESTAMP=$BUILD_TIMESTAMP" >> $GITHUB_ENV | |
- name: download and inject punq-frontend | |
run: | | |
curl https://github.com/mogenius/punq-frontend/releases/download/latest/latest.tar.gz -L -o ui.tar.gz | |
mkdir -p ui/dist | |
tar -xzf ui.tar.gz -C ui/dist | |
- name: Authenticate GitHub CLI | |
run: gh auth login --with-token <<< "${{ secrets.PUNQ_TOKEN }}" | |
- name: Execute make all | |
shell: bash -ieo pipefail {0} | |
run: | | |
make all | |
- name: Upload binaries | |
run: | | |
ls -lisa builds | |
for build in builds/*; do | |
gh release upload ${{ env.VERSION }} "$build" --repo mogenius/punq | |
done | |
env: | |
GH_TOKEN: ${{ secrets.PUNQ_TOKEN }} | |
- name: Create release in another repo | |
run: | | |
gh release create refs/tags/${{ env.VERSION }} --title "Release ${{ env.VERSION }}" --repo mogenius/homebrew-punq | |
env: | |
GH_TOKEN: ${{ secrets.PUNQ_TOKEN }} | |
- name: Package artefacts | |
run: | | |
for file in builds/*; do | |
tar -czvf builds/$(basename "$file").tar.gz -C builds $(basename "$file") | |
done | |
ls -lisa builds | |
- name: Upload tarballs | |
run: | | |
ls -lisa builds | |
for tarball in builds/*.tar.gz; do | |
gh release upload ${{ env.VERSION }} "$tarball" --repo mogenius/homebrew-punq | |
done | |
env: | |
GH_TOKEN: ${{ secrets.PUNQ_TOKEN }} | |
- name: UPDATE BREW | |
run: | | |
./release.sh | |
git clone https://${{secrets.PUNQ_TOKEN}}@github.com/mogenius/homebrew-punq | |
cd homebrew-punq | |
cp ../punq.rb . | |
git add punq.rb | |
git commit -m "[skip ci] ${{ env.VERSION }}" | |
git push | |
env: | |
GH_TOKEN: ${{ secrets.PUNQ_TOKEN }} | |
- name: UPDATE SCOOP | |
run: | | |
git add punq.json | |
git commit -m "[skip ci] scoop ${{ env.VERSION }}" | |
git push | |
env: | |
GH_TOKEN: ${{ secrets.PUNQ_TOKEN }} | |
build-amd64: | |
needs: prepare | |
runs-on: [self-hosted, X64] | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.PUNQ_TOKEN }} | |
- name: download and inject punq-frontend | |
run: | | |
curl https://github.com/mogenius/punq-frontend/releases/download/latest/latest.tar.gz -L -o ui.tar.gz | |
mkdir -p ui/dist | |
tar -xzf ui.tar.gz -C ui/dist | |
- name: Build and push AMD64 image | |
run: | | |
VERSION=$(git describe --tags $(git rev-list --tags --max-count=1)) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
GIT_BRANCH=$(git branch | grep \* | cut -d ' ' -f2 | tr '[:upper:]' '[:lower:]') | |
COMMIT_HASH=$(git rev-parse --short HEAD) | |
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
BUILD_TIMESTAMP=$(date -Iseconds) | |
OPERATOR_IMAGE="${{ env.IMAGE_NAME }}:$VERSION" | |
docker build -f ${{ env.DOCKERFILE }} --build-arg GOOS=linux --build-arg GOARCH=amd64 --build-arg VERSION="$VERSION" --build-arg OPERATOR_IMAGE="$OPERATOR_IMAGE" --build-arg BUILD_TIMESTAMP="$BUILD_TIMESTAMP" --build-arg GIT_BRANCH="$GIT_BRANCH" --build-arg COMMIT_HASH="$COMMIT_HASH" -t ${{ env.IMAGE_NAME }}:$VERSION-amd64 -t ${{ env.IMAGE_NAME }}:latest-amd64 . | |
docker push ${{ env.IMAGE_NAME }}:$VERSION-amd64 | |
build-arm64-linux: | |
needs: prepare | |
runs-on: [self-hosted, ARM64] | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.PUNQ_TOKEN }} | |
- name: download and inject punq-frontend | |
run: | | |
curl https://github.com/mogenius/punq-frontend/releases/download/latest/latest.tar.gz -L -o ui.tar.gz | |
mkdir -p ui/dist | |
tar -xzf ui.tar.gz -C ui/dist | |
- name: Build and push ARM64-linux image | |
run: | | |
VERSION=$(git describe --tags $(git rev-list --tags --max-count=1)) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
GIT_BRANCH=$(git branch | grep \* | cut -d ' ' -f2 | tr '[:upper:]' '[:lower:]') | |
COMMIT_HASH=$(git rev-parse --short HEAD) | |
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
BUILD_TIMESTAMP=$(date -Iseconds) | |
OPERATOR_IMAGE="${{ env.IMAGE_NAME }}:$VERSION" | |
docker build --platform=linux/arm64 -f ${{ env.DOCKERFILE }} --build-arg GOOS=linux --build-arg GOARCH=arm64 --build-arg VERSION="$VERSION" --build-arg OPERATOR_IMAGE="$OPERATOR_IMAGE" --build-arg BUILD_TIMESTAMP="$BUILD_TIMESTAMP" --build-arg GIT_BRANCH="$GIT_BRANCH" --build-arg COMMIT_HASH="$COMMIT_HASH" -t ${{ env.IMAGE_NAME }}:$VERSION-arm64-linux -t ${{ env.IMAGE_NAME }}:latest-arm64-linux . | |
docker push ${{ env.IMAGE_NAME }}:$VERSION-arm64-linux | |
merge-images: | |
needs: [build-amd64, build-arm64-linux, prepare] | |
runs-on: self-hosted | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.PUNQ_TOKEN }} | |
- name: Merge images into a multi-arch manifest | |
run: | | |
VERSION=$(git describe --tags $(git rev-list --tags --max-count=1)) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
docker manifest create ${{ env.IMAGE_NAME }}:$VERSION \ | |
--amend ${{ env.IMAGE_NAME }}:$VERSION-amd64 \ | |
--amend ${{ env.IMAGE_NAME }}:$VERSION-arm64-linux | |
docker manifest push ${{ env.IMAGE_NAME }}:$VERSION | |
docker manifest create ${{ env.IMAGE_NAME }}:latest \ | |
--amend ${{ env.IMAGE_NAME }}:$VERSION-amd64 \ | |
--amend ${{ env.IMAGE_NAME }}:$VERSION-arm64-linux | |
docker manifest push ${{ env.IMAGE_NAME }}:latest |