Skip to content

Commit

Permalink
Add workflow for automated releases.
Browse files Browse the repository at this point in the history
When a new version tag is pushed, the workflow automatically runs tests
(currently only on linux), produces an executable for each target
system, creates a draft release for the pushed tag, and uploads each
generated executable to the release.

Afterwards, the only manual work required is filling out a description,
then publishing the draft.
  • Loading branch information
Anaminus committed Feb 15, 2021
1 parent 285ef8a commit c48d4f1
Showing 1 changed file with 114 additions and 0 deletions.
114 changes: 114 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Create draft release

on:
push:
tags:
- 'v*.*.*'

env:
PROJECT : 'rbxmk' # Name of project/executable.
PROGRAM : '.' # Location of program.
GOVERSION : 1.15 # Version of Go to compile with.
DIST : './dist' # Scratch directory for building executables.

jobs:

test:
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{env.GOVERSION}}

- name: Run tests
run: go test -v ${{env.PROGRAM}}

build:
name: Build executables
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
include:
- {os: 'windows' , arch: 'amd64' , output: './dist/playground.exe'}
- {os: 'windows' , arch: '386' , output: './dist/playground.exe'}
- {os: 'darwin' , arch: 'amd64' , output: './dist/playground'}
- {os: 'linux' , arch: '386' , output: './dist/playground'}
- {os: 'linux' , arch: 'amd64' , output: './dist/playground'}
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{env.GOVERSION}}

- name: Set version variable
run: echo VERSION=${GITHUB_REF#refs/tags/} >> $GITHUB_ENV

- name: Make build directory
run: mkdir ${{env.DIST}}

- name: Build executable
env:
GOOS: ${{matrix.os}}
GOARCH: ${{matrix.arch}}
OUTPUT: ${{matrix.output}}
run: go build -v -o $OUTPUT ${{env.PROGRAM}}

- name: Create archive
id: archive
env:
GOOS: ${{matrix.os}}
GOARCH: ${{matrix.arch}}
OUTPUT: ${{matrix.output}}
run: |
NAME=$PROJECT-$VERSION-$GOOS-$GOARCH
ARCHIVE=${{env.DIST}}/$NAME.zip
zip --junk-paths $ARCHIVE $OUTPUT
echo ::set-output name=name::$NAME
echo ::set-output name=path::$ARCHIVE
- name: Upload executable
uses: actions/upload-artifact@v2
with:
name: ${{steps.archive.outputs.name}}
path: ${{steps.archive.outputs.path}}
if-no-files-found: error
retention-days: 1

release:
name: Create release
needs: [test, build]
runs-on: ubuntu-latest
steps:
- name: Set version variable
run: echo VERSION=${GITHUB_REF#refs/tags/} >> $GITHUB_ENV

- name: Download all archives
id: download
uses: actions/download-artifact@v2

- name: Move files
run: |
mkdir files
mv $(find ${{steps.download.outputs.download-path}} -iname *.zip) files
- name: Check files
run: find .

- name: Create release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
name: ${{env.PROJECT}} ${{env.VERSION}}
body: TODO
draft: true
files: files/*.zip

0 comments on commit c48d4f1

Please sign in to comment.