Skip to content

Commit

Permalink
Migrate builder to reusable workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
waybackarchiver committed Nov 12, 2022
1 parent 9b96299 commit 6f60557
Showing 1 changed file with 56 additions and 265 deletions.
321 changes: 56 additions & 265 deletions .github/workflows/builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ on:
- "go.sum"
workflow_dispatch:

env:
PRODUCT: wayback
WAYBACK_IPFS_APIKEY: ${{ secrets.WAYBACK_IPFS_APIKEY }}

permissions: write-all
permissions:
contents: read

jobs:
build:
Expand Down Expand Up @@ -86,73 +83,19 @@ jobs:
- os: dragonfly
arch: 386
fail-fast: false
runs-on: ubuntu-latest
continue-on-error: true
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
GOARM: ${{ matrix.arm }}
GOMIPS: ${{ matrix.mips }}
GOMIPS64: ${{ matrix.mips64 }}
GOMIPSLE: ${{ matrix.mipsle }}
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ^1.18

- name: Check out code base
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Check out code base
if: github.event_name == 'pull_request'
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Cache go module
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
~/Library/Caches/go-build
~\AppData\Local\go-build
~\go\pkg\mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Build binary
id: builder
run: |
ARGS="${GOOS}-${GOARCH}"
if [[ -n "${GOARM}" ]]; then
ARGS="${ARGS}v${GOARM}"
elif [[ -n "${GOMIPS}" ]]; then
ARGS="${ARGS}-${GOMIPS}"
elif [[ -n "${GOMIPS64}" ]]; then
ARGS="${ARGS}-${GOMIPS64}"
elif [[ -n "${GOMIPSLE}" ]]; then
ARGS="${ARGS}-${GOMIPSLE}"
fi
make ${ARGS}
echo "filename=${{ env.PRODUCT }}-${ARGS}" >> $GITHUB_OUTPUT
- name: Upload binary artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ steps.builder.outputs.filename }}
path: ./build/binary/${{ env.PRODUCT }}*
if-no-files-found: error
uses: wabarc/.github/.github/workflows/reusable-builder-go.yml@main
with:
product: wayback
go-version: '^1.19'
go-os: ${{ matrix.os }}
go-arch: ${{ matrix.arch }}
go-arm: ${{ matrix.arm }}
go-mips: ${{ matrix.mips }}
go-mips64: ${{ matrix.mips64 }}
go-mipsle: ${{ matrix.mipsle }}
artifact-path: ./build/binary/wayback*
secrets:
wayback-ipfs-apikey: ${{ secrets.WAYBACK_IPFS_APIKEY }}

debpkg:
name: Build deb
Expand All @@ -168,208 +111,56 @@ jobs:
arch: arm64
arm: 8
fail-fast: false
runs-on: ubuntu-latest
continue-on-error: true
env:
GOARCH: ${{ matrix.arch }}
GOARM: ${{ matrix.arm }}
steps:
- name: Check out code base
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Check out code base
if: github.event_name == 'pull_request'
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up QEMU
uses: docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8 # v2.0.0

- name: Build Debian package
id: builder
run: |
TARGET="${GOARCH}"
if [[ -n "${GOARM}" ]]; then
TARGET="${GOARCH}v${GOARM}"
fi
PKG_ARCH="${TARGET//v8}"
PKG_ARCH="${PKG_ARCH//32}"
make debian DEB_IMG_ARCH=${TARGET} PKG_ARCH=${PKG_ARCH}
echo "filename=${{ env.PRODUCT }}-deb-${PKG_ARCH}" >> $GITHUB_OUTPUT
- name: Upload archived binary
uses: actions/upload-artifact@v3
with:
name: ${{ steps.builder.outputs.filename }}
path: build/package/${{ env.PRODUCT }}*.deb
if-no-files-found: error
uses: wabarc/.github/.github/workflows/reusable-builder-debian.yml@main
with:
product: wayback
go-arch: ${{ matrix.arch }}
go-arm: ${{ matrix.arm }}
artifact-path: build/package/wayback*.deb
secrets:
wayback-ipfs-apikey: ${{ secrets.WAYBACK_IPFS_APIKEY }}

rpmpkg:
name: Build RPM
runs-on: ubuntu-latest
steps:
- name: Check out code base
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Check out code base
if: github.event_name == 'pull_request'
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Build RPM package
run: make rpm

- name: Upload archived binary
uses: actions/upload-artifact@v3
with:
name: ${{ env.PRODUCT }}-rpm
path: build/package/${{ env.PRODUCT }}*.rpm
if-no-files-found: error
uses: wabarc/.github/.github/workflows/reusable-builder-rpm.yml@main
with:
product: wayback
params: 'make rpm'
artifact-path: build/package/wayback*.rpm
secrets:
wayback-ipfs-apikey: ${{ secrets.WAYBACK_IPFS_APIKEY }}

aurpkg:
name: Build AUR
runs-on: ubuntu-latest
steps:
- name: Check out code base
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true

- name: Check out code base
if: github.event_name == 'pull_request'
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
ref: ${{ github.event.pull_request.head.sha }}

- name: Build AUR package
run: |
make submodule
cd build/aur
make volume
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.PRODUCT }}-aur
path: |
build/aur/.SRCINFO
build/aur/PKGBUILD
build/aur/${{ env.PRODUCT }}*.pkg.tar.zst
if-no-files-found: error

- name: Clean up
run: |
cd build/aur
make clean
uses: wabarc/.github/.github/workflows/reusable-builder-aur.yml@main
with:
product: wayback
params: 'make submodule && cd build/aur && make volume'
artifact-path: |
build/aur/.SRCINFO
build/aur/PKGBUILD
build/aur/wayback*.pkg.tar.zst
secrets:
wayback-ipfs-apikey: ${{ secrets.WAYBACK_IPFS_APIKEY }}

snapcraft:
name: Build Snap
runs-on: ubuntu-latest
steps:
- name: Check out code base
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Check out code base
if: github.event_name == 'pull_request'
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up QEMU
uses: docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8 # v2.0.0

- id: build
name: Build Snap
uses: snapcore/action-build@ea14cdeb353272f75977040488ca191880509a8c # v1.1.0
with:
snapcraft-channel: edge

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.PRODUCT }}-snap
path: ${{ steps.build.outputs.snap }}

- name: Install snap
shell: bash
run: |
sudo snap install --dangerous ${{ steps.build.outputs.snap }}
wayback --help
- name: Release Snap
uses: snapcore/action-publish@128198fd2ed6446f70918a2a2d3ae7cbe758bf3a # v1.1.0
if: github.repository == 'wabarc/wayback' && github.event_name == 'push'
with:
store_login: ${{ secrets.SNAPCRAFT_TOKEN }}
snap: ${{ steps.build.outputs.snap }}
release: edge
uses: wabarc/.github/.github/workflows/reusable-builder-snap.yml@main
with:
product: wayback
channel: edge
publish: ${{ github.repository == 'wabarc/wayback' && github.event_name == 'push' }}
secrets:
wayback-ipfs-apikey: ${{ secrets.WAYBACK_IPFS_APIKEY }}
snapcraft-token: ${{ secrets.SNAPCRAFT_TOKEN }}

flatpak:
name: Build Flatpak
runs-on: ubuntu-latest
steps:
- name: Check out code base
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Check out code base
if: github.event_name == 'pull_request'
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ^1.18

- name: Setup Flatpak
run: |
sudo apt-get -y -qq update
sudo apt-get install -y flatpak flatpak-builder
- name: Packaging flatpak
run: |
VERSION=edge
BUNDLE="org.wabarc.wayback_${VERSION}_x86_64.flatpak"
MANIFEST_PATH=$GITHUB_WORKSPACE/build/flatpak/org.wabarc.wayback.yml
RUNTIME_REPO="https://flathub.org/repo/flathub.flatpakrepo"
APP_ID="org.wabarc.wayback"
BRANCH="master"
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install -y --noninteractive flathub org.freedesktop.Platform//20.08 org.freedesktop.Sdk//20.08
make build
mv build/binary/wayback build/flatpak/wayback
flatpak-builder --user --disable-rofiles-fuse --repo=repo --force-clean flatpak_app ${MANIFEST_PATH} --install-deps-from=flathub
flatpak build-bundle repo ${BUNDLE} --runtime-repo=${RUNTIME_REPO} ${APP_ID} ${BRANCH}
mv $GITHUB_WORKSPACE/org.wabarc.wayback_${VERSION}_x86_64.flatpak $GITHUB_WORKSPACE/org.wabarc.wayback-${VERSION}.x86_64.flatpak
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.PRODUCT }}-flatpak
path: org.wabarc.wayback-*.x86_64.flatpak
uses: wabarc/.github/.github/workflows/reusable-builder-flatpak.yml@main
with:
product: wayback
version: edge
params: 'make build'
artifact-path: org.wabarc.wayback-*.x86_64.flatpak
secrets:
wayback-ipfs-apikey: ${{ secrets.WAYBACK_IPFS_APIKEY }}

0 comments on commit 6f60557

Please sign in to comment.