update dependencies due to security alerts #144
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: Compile and Upload Binaries | |
on: | |
release: | |
types: [published] | |
push: | |
tags-ignore: | |
# ignore all pushed tags | |
- '**' | |
branches: | |
# run for all branches | |
- '**' | |
jobs: | |
assemble-os-matrix: | |
runs-on: ubuntu-22.04 | |
name: Assemble Matrix | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Create Matrix | |
id: set-matrix | |
run: ./ci/target-matrix.sh >> "$GITHUB_OUTPUT" | |
go-build: | |
needs: [assemble-os-matrix] | |
name: Go Build | |
strategy: | |
matrix: ${{ fromJson(needs.assemble-os-matrix.outputs.matrix) }} | |
runs-on: ${{ matrix.buildplatform }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21.x' | |
check-latest: true | |
cache-dependency-path: dbee/go.sum | |
- name: Setup Zig for C Cross Compilation | |
uses: goto-bus-stop/setup-zig@v2 | |
- name: Build | |
id: build | |
working-directory: dbee | |
shell: bash | |
run: | | |
bin="dbee" | |
[ '${{ matrix.goos }}' = "windows" ] && bin="dbee.exe" | |
artefact="dbee_${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz" | |
echo "artefact=$artefact" >> "$GITHUB_OUTPUT" | |
../ci/build.sh \ | |
-o "${{ matrix.goos }}" \ | |
-a "${{ matrix.goarch }}" \ | |
-c "${{ matrix.crossarch }}" \ | |
-b "${{ matrix.buildtags }}" \ | |
-e "${{ matrix.cgo }}" \ | |
-p "../ci_tmp/bin/$bin" | |
tar -C "../ci_tmp/bin" -czvf "../ci_tmp/bin/$artefact" "$bin" | |
- name: Upload artefacts to release | |
if: github.event_name == 'release' | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
file: ci_tmp/bin/${{ steps.build.outputs.artefact }} | |
tag: ${{ github.ref }} | |
- name: Create metadata | |
if: github.event_name == 'release' | |
shell: bash | |
run: | | |
mkdir ci_tmp/meta | |
echo "${{ github.server_url }}/${{ github.repository }}/releases/download/${{ github.ref_name }}/${{ steps.build.outputs.artefact }}" > ci_tmp/meta/url | |
echo "${{ matrix.goos }}" > ci_tmp/meta/os | |
echo "${{ matrix.goarch }}" > ci_tmp/meta/arch | |
- name: Upload metadata | |
if: github.event_name == 'release' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.goos }}_${{ matrix.goarch }} | |
path: ci_tmp/meta/* | |
create-install-manifest: | |
runs-on: ubuntu-22.04 | |
if: github.event_name == 'release' | |
name: Create Install Manifest | |
needs: [go-build] | |
env: | |
MANIFEST_FILE: "lua/dbee/install/__manifest.lua" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get metadata | |
uses: actions/download-artifact@v3 | |
with: | |
path: meta | |
- name: Create Install File from metadata | |
run: | | |
{ | |
echo "-- This file is automatically generated using CI pipeline" | |
echo "-- DO NOT EDIT!" | |
echo "local M = {}" | |
echo | |
echo "-- Links to binary releases" | |
echo "M.urls = {" | |
for art in meta/*; do | |
os="$(cat "$art/os")" | |
arch="$(cat "$art/arch")" | |
url="$(cat "$art/url")" | |
echo " [\"$os/$arch\"] = \"$url\"," | |
done | |
echo "}" | |
echo | |
echo "-- Git sha of compiled binaries" | |
echo "M.version = \"${{ github.sha }}\"" | |
echo | |
echo "return M" | |
} > "$MANIFEST_FILE" | |
- name: Commit Generated Manifest | |
shell: bash | |
run: | | |
echo "fetching" | |
git fetch | |
branch=$(basename "$(git branch -r --contains="${{ github.ref }}" | head -n1 | cut -c3-)") | |
echo "checking out" | |
git pull origin "$branch" --rebase --autostash | |
git checkout "$branch" | |
echo "committing" | |
git add "${{ env.MANIFEST_FILE }}" | |
git config user.name "Github Actions" | |
git config user.email "actions@github.com" | |
git commit -m "[install] update install manifest" | |
echo "pushing" | |
git push -u origin "$branch" | |
echo "moving tag" | |
git tag -f "${{ github.ref_name }}" | |
git push origin -f --tags |