Skip to content

Commit

Permalink
Switch to Flowzone
Browse files Browse the repository at this point in the history
Change-type: patch
Signed-off-by: Leandro Motta Barros <leandro@balena.io>
  • Loading branch information
lmbarros authored and ab77 committed Nov 15, 2022
1 parent ad3f3a0 commit 6506028
Show file tree
Hide file tree
Showing 17 changed files with 380 additions and 92 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
.gopath
bundles
vendor/pkg

38 changes: 38 additions & 0 deletions .github/actions/always/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: cleanup
# https://github.com/product-os/flowzone/tree/master/.github/actions
inputs:
json:
description: "JSON stringified object containing all the inputs from the calling workflow"
required: true
secrets:
description: "JSON stringified object containing all the secrets from the calling workflow"
required: true

# --- custom environment
VERBOSE:
type: string
default: "true"

runs:
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
using: "composite"
steps:
# delete draft releases if the pull request is closed without merging
- name: Delete draft release
if: |
runner.os == 'Linux' &&
github.event_name == 'pull_request' &&
github.event.pull_request.merged == false &&
github.event.action == 'closed'
shell: bash
run: |
set -ea
[[ '${{ inputs.VERBOSE }}' =~ on|On|Yes|yes|true|True ]] && set -x
gh release delete --yes '${{ github.event.pull_request.head.ref }}' || true
env:
GITHUB_TOKEN: ${{ fromJSON(inputs.secrets).FLOWZONE_TOKEN }}
52 changes: 52 additions & 0 deletions .github/actions/finalize/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
name: publish GitHub release
# https://github.com/product-os/flowzone/tree/master/.github/actions
inputs:
json:
description: "JSON stringified object containing all the inputs from the calling workflow"
required: true
secrets:
description: "JSON stringified object containing all the secrets from the calling workflow"
required: true

# --- custom environment
VERBOSE:
type: string
default: "true"

runs:
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
using: "composite"
steps:
# https://docs.github.com/en/rest/releases
- name: Finalize release
if: runner.os == 'Linux'
shell: bash
run: |
set -ea
[[ '${{ inputs.VERBOSE }}' =~ on|On|Yes|yes|true|True ]] && set -x
# prevent git from existing with 141
set +o pipefail
current_version="v$(yq e '.[0].version' .versionbot/CHANGELOG.yml)"
previous_version="v$(yq e '.[1].version' .versionbot/CHANGELOG.yml)"
release_notes="$(git log ${previous_version}..HEAD --pretty=reference)"
gh release edit '${{ github.event.pull_request.head.ref }}' \
--notes "${release_notes}" \
--title "${current_version}" \
--tag "${current_version}" \
--prerelease=false \
--draft=false
release_id="$(gh api "/repos/${{ github.repository }}/releases/tags/${current_version}" \
-H 'Accept: application/vnd.github+json' | jq -r .id)"
gh api --method PATCH "/repos/${{ github.repository }}/releases/${release_id}" \
-H 'Accept: application/vnd.github+json' \
-F make_latest="true"
env:
GITHUB_TOKEN: ${{ fromJSON(inputs.secrets).FLOWZONE_TOKEN }}
67 changes: 67 additions & 0 deletions .github/actions/publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
name: build and draft GitHub release
# https://github.com/product-os/flowzone/tree/master/.github/actions
inputs:
json:
description: "JSON stringified object containing all the inputs from the calling workflow"
required: true
secrets:
description: "JSON stringified object containing all the secrets from the calling workflow"
required: true

# --- custom environment
VERBOSE:
type: string
default: "true"

runs:
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
using: "composite"
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# https://github.com/moby/moby/blob/master/.github/workflows
- name: Build release
uses: docker/bake-action@v2
with:
targets: cross
env:
DOCKER_CROSSPLATFORMS: ${{ env.matrix_value }}

# https://github.com/product-os/scripts/tree/master/balena-engine
# https://github.com/product-os/ci-images/tree/master/pipelines/balena-engine
# https://github.com/product-os/balena-concourse/blob/master/pipelines/github-events/template.yml
- name: Package release
shell: bash
run: |
set -ea
[[ '${{ inputs.VERBOSE }}' =~ on|On|Yes|yes|true|True ]] && set -x
version="v$(yq e '.[0].version' .versionbot/CHANGELOG.yml)"
arch="$(echo '${{ env.matrix_value }}' \
| sed 's#linux/##g' \
| sed 's#arm/v#armv#g' \
| sed 's#v5#v5e#g' \
| sed 's#v6#v6l#g' \
| sed 's#v7#v7hf#g')"
mkdir -p dist
tar -czvf dist/balena-engine-${version}-${arch}.tar.gz \
-C bundles/cross/${{ env.matrix_value }} .
# https://github.com/softprops/action-gh-release#-customizing
- name: Publish release assets
uses: softprops/action-gh-release@v1
with:
# use PR branch name for draft releases
name: ${{ github.event.pull_request.head.ref }}
tag_name: ${{ github.event.pull_request.head.ref }}
draft: true
prerelease: true
token: ${{ fromJSON(inputs.secrets).FLOWZONE_TOKEN }}
files: |
dist/*.tar.gz
42 changes: 42 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: prepare draft release
# https://github.com/product-os/flowzone/tree/master/.github/actions
inputs:
json:
description: "JSON stringified object containing all the inputs from the calling workflow"
required: true
secrets:
description: "JSON stringified object containing all the secrets from the calling workflow"
required: true

# --- custom environment
VERBOSE:
type: string
default: "true"

runs:
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
using: "composite"
steps:
- name: Delete previous draft release
shell: bash
run: |
set -ea
[[ '${{ inputs.VERBOSE }}' =~ on|On|Yes|yes|true|True ]] && set -x
gh release delete --yes '${{ github.event.pull_request.head.ref }}' || true
env:
GITHUB_TOKEN: ${{ fromJSON(inputs.secrets).FLOWZONE_TOKEN }}

# https://github.com/softprops/action-gh-release#-customizing
- name: Create release placeholder
uses: softprops/action-gh-release@v1
with:
# use PR branch name for draft releases
name: ${{ github.event.pull_request.head.ref }}
tag_name: ${{ github.event.pull_request.head.ref }}
draft: true
prerelease: true
token: ${{ fromJSON(inputs.secrets).FLOWZONE_TOKEN }}
17 changes: 17 additions & 0 deletions .github/workflows/flowzone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Flowzone

on:
pull_request:
types: [opened, synchronize, closed]
branches:
- "main"
- "master"

jobs:
flowzone:
name: Flowzone
uses: product-os/flowzone/.github/workflows/flowzone.yml@master
secrets: inherit
with:
# https://github.com/golang/go/blob/master/src/go/build/syslist.go
custom_publish_matrix: "linux/386,linux/amd64,linux/arm/v5,linux/arm/v6,linux/arm/v7,linux/arm64"
3 changes: 0 additions & 3 deletions .resinci.yml

This file was deleted.

Loading

0 comments on commit 6506028

Please sign in to comment.