Skip to content

Commit

Permalink
build(github): ♻️ reorganise and clean up workflow files
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuar committed Apr 25, 2024
1 parent d0e049f commit 192a4c2
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 221 deletions.
105 changes: 88 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ jobs:
> ${RUNNER_TEMP}/dpkg.log
env:
DEBIAN_FRONTEND: noninteractive
# - name: Install/Cache dependencies
# id: cache_pkg_deps
# uses: awalsh128/cache-apt-pkgs-action@latest
# with:
# packages: desktop-file-utils gcc libgl1-mesa-dev libegl1-mesa-dev libgles2-mesa-dev libx11-dev xorg-dev dbus-x11
- name: Set up Go
id: setup_go
uses: actions/setup-go@v5
Expand Down Expand Up @@ -117,16 +112,6 @@ jobs:
> ${RUNNER_TEMP}/apt-install.log
env:
DEBIAN_FRONTEND: noninteractive
# - name: Install/Cache build dependencies
# # if: ${{ steps.release_please.outputs.release_created }}
# id: cache_pkg_deps
# uses: awalsh128/cache-apt-pkgs-action@latest
# with:
# packages: >
# desktop-file-utils gcc gcc-arm-none-eabi gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu
# libgl-dev:amd64 libx11-dev:amd64 libxrandr-dev:amd64 libxxf86vm-dev:amd64 libxi-dev:amd64 libxcursor-dev:amd64 libxinerama-dev:amd64 libxkbcommon-dev:amd64
# libgl-dev:armhf libx11-dev:armhf libxrandr-dev:armhf libxxf86vm-dev:armhf libxi-dev:armhf libxcursor-dev:armhf libxinerama-dev:armhf libxkbcommon-dev:armhf
# libgl-dev:arm64 libx11-dev:arm64 libxrandr-dev:arm64 libxxf86vm-dev:arm64 libxi-dev:arm64 libxcursor-dev:arm64 libxinerama-dev:arm64 libxkbcommon-dev:arm64
- name: Setup Go
id: setup_go
uses: actions/setup-go@v5
Expand All @@ -141,7 +126,6 @@ jobs:
go install github.com/matryer/moq@latest
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest
- name: Build ${{ matrix.arch }} binary
# if: ${{ steps.release_please.outputs.release_created }}
id: build_binary
run: |
source ${BUILD_ENV}
Expand Down Expand Up @@ -198,4 +182,91 @@ jobs:
dist/*.{rpm,deb,zst,sig} fyne-cross/dist/linux-${{ matrix.arch }}/*.{tar.xz,sig}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


build_container:
runs-on: ubuntu-20.04
env:
REGISTRY: ghcr.io
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
IMAGE: ${{ github.repository }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install/Cache dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: qemu-user-static
- name: Get Docker metadata
id: docker_metadata
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE }}
tags: |
type=raw,value=latest
type=edge
type=sha
type=ref,event=branch
type=ref,event=pr
type=schedule
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
- uses: cardinalby/git-get-release-action@v1
id: release_metadata
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
latest: true
- name: Build container image
id: build_image
uses: redhat-actions/buildah-build@v2
with:
archs: amd64
image: ${{ env.IMAGE }}
tags: ${{ steps.docker_metadata.outputs.tags }} ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ steps.release_metadata.outputs.name }}
labels: ${{ steps.docker_metadata.outputs.labels }}
containerfiles: Dockerfile
layers: false
oci: true
- name: Push to Container Registry
id: push_image
uses: redhat-actions/push-to-registry@v2
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
with:
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
tags: ${{ steps.build_image.outputs.tags }}
extra-args: |
--disable-content-trust
- name: Login to Container Registry
uses: redhat-actions/podman-login@v1
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
- name: Check and install cosign
uses: sigstore/[email protected]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
with:
cosign-release: 'v2.2.2'
- name: Sign image with a key
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
DIGEST: ${{ steps.push_image.outputs.digest }}
TAGS: ${{ steps.docker_metadata.outputs.tags }} ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ steps.release_metadata.outputs.name }}
COSIGN_PASSWORD: ${{ secrets.COSIGN_PWD }}
run: |
images=""
for tag in ${TAGS}; do
images+="${tag}@${DIGEST} "
done
cosign --verbose=true sign --yes --key cosign.key \
-a "repo=${{ github.repository }}" \
-a "ref=${{ github.ref }}" \
${images}
File renamed without changes.
101 changes: 0 additions & 101 deletions .github/workflows/release-container.yml

This file was deleted.

88 changes: 0 additions & 88 deletions .github/workflows/release-please.yml

This file was deleted.

34 changes: 19 additions & 15 deletions .github/workflows/go-test.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
name: Run go tests
name: Test

on:
push:
branches: [ main ]

permissions:
contents: write
pull-requests: write

jobs:
test:
runs-on: ubuntu-latest
Expand All @@ -13,41 +17,41 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install/Cache dependencies
id: cache_pkg_deps
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: desktop-file-utils gcc libgl1-mesa-dev libegl1-mesa-dev libgles2-mesa-dev libx11-dev xorg-dev dbus-x11

- name: Install build dependencies
id: install_packages
run: >
sudo apt-get update && sudo apt-get -y install
desktop-file-utils gcc
libgl1-mesa-dev xserver-xorg-dev
libxcursor-dev libxrandr-dev
libxinerama-dev libxi-dev
libgl1-mesa-dev libxxf86vm-dev
> ${RUNNER_TEMP}/dpkg.log
env:
DEBIAN_FRONTEND: noninteractive
- name: Set up Go
id: setup_go
uses: actions/setup-go@v5
with:
go-version: '^1.22'

- name: Install Go dependencies
id: install_go_deps
run: |
go install golang.org/x/tools/cmd/stringer@latest
go install github.com/fyne-io/fyne-cross@latest
go install golang.org/x/text/cmd/gotext@latest
go install github.com/matryer/moq@latest
- name: Run go generate
id: go_generate
run: go generate -v ./...

- name: Run go build
id: go_build
run: go build -v ./...

run: go build -v
- name: Run go test
id: go_test
run: go test -v -coverprofile=coverage.txt ./...
continue-on-error: true

- name: Upload Coverage
id: upload_coverage
uses: codecov/codecov-action@v4
continue-on-error: true
with:
Expand Down

0 comments on commit 192a4c2

Please sign in to comment.