From 89efe0cc86441e417d21e891f7f83544bd296fce Mon Sep 17 00:00:00 2001 From: icex2 Date: Mon, 10 Apr 2023 23:54:37 +0200 Subject: [PATCH] feat(dev): Add github build and release workflows --- .github/workflows/build-master.yaml | 39 ++++++++++++++++ .github/workflows/build-tag.yaml | 71 +++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 .github/workflows/build-master.yaml create mode 100644 .github/workflows/build-tag.yaml diff --git a/.github/workflows/build-master.yaml b/.github/workflows/build-master.yaml new file mode 100644 index 0000000..2f4b64d --- /dev/null +++ b/.github/workflows/build-master.yaml @@ -0,0 +1,39 @@ +name: "Build bemanitools" + +on: + push: + branches: + - master + +jobs: + build: + runs-on: "ubuntu-22.04" + steps: + - name: "Checkout repository" + uses: "actions/checkout@v2" + + - name: "Install prerequisites" + run: | + sudo apt-get update + sudo apt-get install -y runc containerd docker.io + + - name: "Build" + run: | + make build-docker + + # Do some unpacking of the dist zip. Artifact upload repackages stuff + - name: "Prepare artifact package" + run: | + mkdir artifact + cd artifact + unzip ../build/bemanitools.zip + cd .. + + - name: "Upload artifact" + uses: "actions/upload-artifact@v2" + with: + name: bemanitools-${{ github.sha }} + retention-days: 90 + if-no-files-found: "error" + path: | + artifact/** diff --git a/.github/workflows/build-tag.yaml b/.github/workflows/build-tag.yaml new file mode 100644 index 0000000..d00cf7c --- /dev/null +++ b/.github/workflows/build-tag.yaml @@ -0,0 +1,71 @@ +name: "Build bemanitools" + +on: + push: + tags: + - "*.*" + +jobs: + build: + runs-on: "ubuntu-22.04" + steps: + - name: "Checkout repository" + uses: "actions/checkout@v2" + + # Building bootstrapped using docker containers + - name: "Install prerequisites" + run: | + sudo apt-get update + sudo apt-get install -y runc containerd docker.io + + - name: "Build" + run: | + make build-docker + + # Do some unpacking of the dist zip. Artifact upload repackages stuff + - name: "Prepare artifact package" + run: | + mkdir artifact + cd artifact + unzip ../build/bemanitools.zip + cd .. + + - name: "Upload artifact" + uses: "actions/upload-artifact@v2" + with: + name: bemanitools-${{ github.sha }} + retention-days: 90 + if-no-files-found: "error" + path: | + artifact/** + + publish-release: + needs: "build" + runs-on: "ubuntu-22.04" + steps: + # This already extracts the contents of the artifact + - name: "Download artifact" + uses: "actions/download-artifact@v2" + with: + name: bemanitools-${{ github.sha }} + + - name: "Get the version" + id: get_version + run: | + echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3) + + # The publish release action does not package the artifact *sigh* + - name: "Create release package" + run: | + zip bemanitools-${{ steps.get_version.outputs.VERSION }}.zip * + + - name: "Publish release" + uses: "marvinpinto/action-automatic-releases@v1.2.1" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: "latest" + draft: false + prerelease: true + title: ${{ steps.get_version.outputs.VERSION }} + files: | + bemanitools-${{ steps.get_version.outputs.VERSION }}.zip