Skip to content

👷 #91: Build Windows images #66

👷 #91: Build Windows images

👷 #91: Build Windows images #66

Workflow file for this run

name: release
on:
push:
tags:
- "*"
pull_request:
types:
- synchronize
- labeled
permissions:
contents: write
packages: write
jobs:
setup:
runs-on: ubuntu-latest
outputs:
dry-run: ${{ steps.set-flags.outputs.dry-run }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set flag based on PR label
id: set-flags
run: |
LABELS="${{ toJson(github.event.pull_request.labels.*.name) }}"
DRY_RUN="false"
if [[ $LABELS == *"build:dry-run"* ]]; then
DRY_RUN="true"
fi
echo "dry-run=$DRY_RUN" >> $GITHUB_OUTPUT
# lint:
# uses: ./.github/workflows/lint.yaml
# vuln:
# uses: ./.github/workflows/vuln.yaml
release:
if: "startsWith(github.ref, 'refs/tags/') || needs.setup.outputs.dry-run == 'true'"
needs:
- setup
# - lint
# - vuln
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.22
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Snapcraft Setup
run: |
sudo apt-get update
sudo apt-get -yq --no-install-suggests --no-install-recommends install snapcraft
mkdir -p $HOME/.cache/snapcraft/download
mkdir -p $HOME/.cache/snapcraft/stage-packages
- name: Prepare GoReleaser extra args
run: |
ARGS=""
if [[ "${{ needs.setup.outputs.dry-run }}" == "true" ]]; then
ARGS="$ARGS --skip=validate --skip-publish"
fi
echo "GORELEASER_EXTRA_ARGS=$ARGS" >> $GITHUB_ENV
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean ${{ env.GORELEASER_EXTRA_ARGS }}
env:
GORELEASER_DRY_RUN: ${{ env.GORELEASER_DRY_RUN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_TOKEN }}
DISCORD_WEBHOOK_ID: ${{ secrets.DISCORD_WEBHOOK_ID }}
DISCORD_WEBHOOK_TOKEN: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
BREW_TAP_PRIVATE_KEY: ${{ secrets.BREW_TAP_PRIVATE_KEY }}
images-linux:
if: "startsWith(github.ref, 'refs/tags/') || needs.setup.outputs.dry-run == 'true'"
strategy:
matrix:
image:
- alpine
- ubuntu
- distroless
- redhat
runs-on: ubuntu-latest
needs:
- release
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: login into Github Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: login into Docker
run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u einstack --password-stdin
- name: build ${{ matrix.image }} image
working-directory: ./images
env:
BUILD_TIME: ${{needs.build_time.outputs.BUILD_TIME}}
run: VERSION=${{ github.ref_name }} COMMIT=$(git rev-parse --short "$GITHUB_SHA") make ${{ matrix.image }}
- name: publish ${{ matrix.image }} image to Github Container Registry
if: "needs.setup.outputs.dry-run != 'true'"
working-directory: ./images
run: VERSION=${{ github.ref_name }} make publish-ghcr-${{ matrix.image }}
- name: publish ${{ matrix.image }} image to DockerHub
if: "needs.setup.outputs.dry-run != 'true'"
working-directory: ./images
run: VERSION=${{ github.ref_name }} make publish-dockerhub-${{ matrix.image }}
images-win:
if: "startsWith(github.ref, 'refs/tags/') || needs.setup.outputs.dry-run == 'true'"
strategy:
matrix:
image:
- nanoserver
- windows-server
needs:
- release
runs-on: windows-2019
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: login into Github Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: login into Docker
run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u einstack --password-stdin
- name: build ${{ matrix.image }} image
working-directory: ./images
env:
BUILD_TIME: ${{needs.build_time.outputs.BUILD_TIME}}
run: VERSION=${{ github.ref_name }} COMMIT=$(git rev-parse --short "$GITHUB_SHA") make ${{ matrix.image }}
- name: publish ${{ matrix.image }} image to Github Container Registry
if: "needs.setup.outputs.dry-run != 'true'"
working-directory: ./images
run: VERSION=${{ github.ref_name }} make publish-ghcr-${{ matrix.image }}
- name: publish ${{ matrix.image }} image to DockerHub
if: "needs.setup.outputs.dry-run != 'true'"
working-directory: ./images
run: VERSION=${{ github.ref_name }} make publish-dockerhub-${{ matrix.image }}