Skip to content

Merge pull request #16 from armory/chore/add_source_commands #17

Merge pull request #16 from armory/chore/add_source_commands

Merge pull request #16 from armory/chore/add_source_commands #17

Workflow file for this run

on:
push:
branches:
- master
- main
name: Build and Release
jobs:
setup:
env:
GRGIT_USER: GitHub
GRGIT_PASS: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-latest
outputs:
version: ${{ steps.push_tag.outputs.new_tag }}
changelog: ${{ steps.changelog.outputs.CHANGELOG }}
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Fetch full history
run: git fetch --prune --tags --unshallow
- name: Create Tag
id: push_tag
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: patch
release_branches: main
create_annotated_tag: false
append_to_pre_release_tag: rc
- name: Fetch Refresh
run: git fetch --prune --tags
- name: Generate Changelog
id: changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export NEW_TAG="${{ steps.push_tag.outputs.new_tag }}"
echo "NEW_TAG=$NEW_TAG"
export PREVIOUS_TAG="${{ steps.push_tag.outputs.previous_tag }}"
echo "PREVIOUS_TAG=$PREVIOUS_TAG"
export CHANGELOG=`git log $NEW_TAG...$PREVIOUS_TAG --oneline`
echo "CHANGELOG=$CHANGELOG"
#Format the changelog so it's markdown compatible
CHANGELOG="${CHANGELOG//$'%'/%25}"
CHANGELOG="${CHANGELOG//$'\n'/%0A}"
CHANGELOG="${CHANGELOG//$'\r'/%0D}"
echo ::set-output name=CHANGELOG::$(echo -e "${CHANGELOG}")
create-release:
name: Create Release
needs: setup
runs-on: ubuntu-latest
outputs:
release-url: ${{ steps.create-release.outputs.upload_url }}
steps:
- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "${{ needs.setup.outputs.version }}"
release_name: ${{ github.event.repository.name }} ${{ needs.setup.outputs.version }}
body: |
${{ needs.setup.outputs.changelog }}
draft: false
prerelease: false
compile:
name: Compile Binaries and Upload to Release
needs:
- setup
- create-release
runs-on: ubuntu-latest
strategy:
matrix:
os: [ darwin, linux ]
arch: [ amd64, arm64 ]
steps:
- name: Checkout Code
uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version-file: 'go.mod'
- name: Cache Dependencies
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: go-${{ hashFiles('**/go.sum') }}
restore-keys: go-
- name: Build CLI
env:
VERSION: ${{ needs.setup.outputs.version }}
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
run: make build
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.release-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/dist/${{ matrix.os }}_${{ matrix.arch }}/avm
asset_name: avm-${{ matrix.os }}-${{ matrix.arch }}
asset_content_type: binary/octet-stream