Skip to content

Commit

Permalink
Merge branch 'main' of gitlab.com:nosana-ci/apps/platform/nosana-node
Browse files Browse the repository at this point in the history
  • Loading branch information
jeisses committed Feb 16, 2023
2 parents fe9c3c4 + 6212c29 commit 8804077
Show file tree
Hide file tree
Showing 2 changed files with 197 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/scripts/prepare-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env bash

# exit upon failure
set -e

# setup
[[ -n "${DEBUG_SCRIPT}" ]] && set -xv

# shell swag
RED="\033[1;91m"
CYAN="\033[1;36m"
GREEN="\033[1;32m"
WHITE="\033[1;38;5;231m"
RESET="\n\033[0m"

# logging
log_std() { echo -e "${CYAN}==> ${WHITE}${1}${RESET}"; }
log_err() { echo -e "${RED}==> ${WHITE}${1}${RESET}"; }

# vars
version=${TAG_REF/refs\/tags\//}
tarball="all-files-${version}.tar.gz"
log_std "Preparing release ${GREEN}${version}"

# create release directory
mkdir release

# artifacts files
cd artifacts
for file in */*; do
cp "${file}" "../release/$(dirname "${file}")-${version}"
done

# release files
cd ../release
for file in *; do
sha256sum "${file}" >"${file}.sha256sum"
done

tar czf "${tarball}" ./*
sha256sum "${tarball}" >"${tarball}.sha256sum"

# release body
cat <<EOF >"../${RELEASE_BODY_FILE}"
## SHA 256
EOF

for file in *.sha256sum; do
echo "- \`$(cut -f 1 -d ' ' <"${file}")\` ${file}" >>"../${RELEASE_BODY_FILE}"
done

cat <<EOF >>"../${RELEASE_BODY_FILE}"
## Change log
EOF
echo "${CHANGE_LOG}" >>"../${RELEASE_BODY_FILE}"

# github output
for output in \
"version=${version}" \
"sha256=$(cut -f 1 -d ' ' <"${tarball}.sha256sum")"; do
echo "${output}" >>"${GITHUB_OUTPUT}"
done
132 changes: 132 additions & 0 deletions .github/workflows/brew.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Build and release Nosana Node packages

on:
push:
tags:
- v*

permissions:
contents: write

jobs:
##############
# BUILD
build:
name: Build package
runs-on: ubuntu-latest

steps:
# repo
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: true

# java
- name: Setup java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 19

# clojure
- name: Setup clojure
uses: DeLaGuardo/[email protected]
with:
cli: latest

# build
- name: Compile uberjar
run: clojure -X:compile uberjar

# artifact
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: nosana-node
path: target/*.jar
if-no-files-found: error

##############
# RELEASE
release:
name: Release package
needs: build
runs-on: ubuntu-latest
env:
RELEASE_BODY_FILE: body.txt
outputs:
version: ${{ steps.prepare.outputs.version }}
sha256: ${{ steps.prepare.outputs.sha256 }}
steps:
# repo
- name: Checkout repository
uses: actions/checkout@v3

# artifact
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: artifacts

# changelog
- name: Generate changelog
id: changelog
uses: metcalfc/[email protected]
with:
myToken: ${{ secrets.GITHUB_TOKEN }}

# prepare
- name: Prepare release files
id: prepare
run: .github/scripts/prepare-release.sh
env:
TAG_REF: ${{ github.ref }}
CHANGE_LOG: ${{ steps.changelog.outputs.changelog }}

# release
- name: Release package
uses: softprops/action-gh-release@v1
with:
body_path: ${{ env.RELEASE_BODY_FILE }}
files: release/*
draft: false
prerelease: false

##############
# UPDATE
update:
name: Update Brew
needs: release
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.release.outputs.version }}
SHA256: ${{ needs.release.outputs.sha256 }}
steps:
# remote repo
- name: Checkout brew sources
uses: actions/checkout@v3
with:
repository: nosana-ci/homebrew-tools

# update formula
- name: Update formula
id: update-formula
run: scripts/update-formula.sh nosana-node.rb ${{ env.VERSION }} ${{ env.SHA256 }}

# create PR
- name: Create PR
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.BOT_GITHUB_PAT_PUBLIC_REPO }}
commit-message: Update nosana-node formula to version ${{ env.VERSION }}
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
base: main
branch: update-nosana-node-cli-formula
delete-branch: true
title: Nosana Node brew update ${{ env.VERSION }}
body: |
This PR
- Updates `nosana-node` formula to version `${{ env.VERSION }}`
- Package sha256 is `${{ env.SHA256 }}`
- Auto-generated from [nosana-ci Continuous Delivery workflow](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})

0 comments on commit 8804077

Please sign in to comment.