Skip to content

reworked pipelines into single workflow #1

reworked pipelines into single workflow

reworked pipelines into single workflow #1

Workflow file for this run

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Build and Release
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
name: Build Go App
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22.1'
- name: Build
run: ./.github/build-all-archs.sh
env:
BUILD_ARCHS: "windows/amd64 darwin/amd64 darwin/arm64 linux/amd64 linux/arm64"
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.3.1
with:
name: dist
path: dist
docker:
name: Build Docker
needs: build
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,format=long
- uses: actions/checkout@v4
- name: Download a Build Artifact
uses: actions/download-artifact@v4.1.4
with:
name: dist
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/arm64, linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=docker,dest=/tmp/docker.tar
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: docker
path: /tmp/docker.tar
outputs:
tags: ${{ steps.meta.outputs.tags }}
release:
name: Build Docker
if: github.event_name != 'pull_request'
needs:
- build
- build-docker

Check failure on line 90 in .github/workflows/build-release.yml

View workflow run for this annotation

GitHub Actions / Build and Release

Invalid workflow file

The workflow is not valid. .github/workflows/build-release.yml (Line: 90, Col: 7): Job 'release' depends on unknown job 'build-docker'.
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Download a Build Artifact
uses: actions/download-artifact@v4.1.4
with:
name: dist
path: dist
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
artifacts: "dist/*"
- name: Download a Build Artifact
uses: actions/download-artifact@v4.1.4
with:
name: docker
path: /tmp
- name: Login to ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Tag and push docker image
run: |
docker load --input /tmp/docker.tar
IFS=. read -r major minor patch <<< $GIT_TAG
dockerImage = "${DOCKER_TAG%%:sha-*}"
for tag in $major "${major}-${minor}" "${major}-${minor}-${patch}"; do
docker tag $DOCKER_TAG $dockerImage:$tag
done
docker push --all-tags $DOCKER_TAG