-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow for automated releases.
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
Showing
1 changed file
with
114 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,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 |