Skip to content

Commit

Permalink
Adds .github workflows
Browse files Browse the repository at this point in the history
Includes:
- running tests for PRs
- creating a release with jam build artifacts
  • Loading branch information
Ryan Moran committed May 11, 2020
1 parent d7060ff commit 7eee3b6
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Create Release

on:
push:
branches:
- master

jobs:
unit:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: 1.14
- name: Checkout
uses: actions/checkout@v2
- name: Run Unit Tests
run: go test -v -count=1 ./...

release:
name: Release
runs-on: ubuntu-latest
needs: unit
steps:
- name: Checkout
uses: actions/checkout@v2
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Tag
id: tag
uses: paketo-buildpacks/github-config/actions/tag@master
- name: Package Jam
run : ./scripts/package.sh
- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.tag }}
release_name: ${{ steps.tag.outputs.tag }}
draft: false
prerelease: false
- name: Upload Jam (darwin)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: build/jam-darwin
asset_name: ${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}.tgz
asset_content_type: application/octet-stream
- name: Upload Jam (linux)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: build/jam-linux
asset_name: ${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}.tgz
asset_content_type: application/octet-stream

20 changes: 20 additions & 0 deletions .github/workflows/test-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Test Pull Request

on:
pull_request:
branches:
- master

jobs:
unit:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: 1.14
- name: Checkout
uses: actions/checkout@v2
- name: Run Unit Tests
run: go test -v -count=1 ./...
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
.idea
/build
22 changes: 22 additions & 0 deletions scripts/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e
set -u
set -o pipefail

readonly ROOT_DIR="$(cd "$(dirname "${0}")/.." && pwd)"
readonly ARTIFACTS_DIR="${ROOT_DIR}/build"

function main() {
mkdir -p "${ARTIFACTS_DIR}"

pushd "${ROOT_DIR}" > /dev/null || return
for os in darwin linux; do
echo "* building jam on ${os}"
GOOS="${os}" GOARCH="amd64" go build -o "${ARTIFACTS_DIR}/jam-${os}" ./cargo/jam/main.go
chmod +x "${ARTIFACTS_DIR}/jam-${os}"
done
popd > /dev/null || return
}

main "${@:-}"

0 comments on commit 7eee3b6

Please sign in to comment.