Skip to content

Commit ce3feb1

Browse files
authored
Switch to GitHub action
1 parent 14f9431 commit ce3feb1

File tree

4 files changed

+165
-76
lines changed

4 files changed

+165
-76
lines changed

.circleci/config.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.circleci/release.sh

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: CI
2+
3+
on: ['pull_request', 'push']
4+
5+
jobs:
6+
build:
7+
name: Build on ${{ matrix.os }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [ubuntu-latest, macOS-latest]
12+
stack: ["2.1.3"]
13+
ghc: ["8.8.3"]
14+
15+
steps:
16+
- name: Get the version
17+
id: get_version
18+
run: 'echo ::set-output name=version::${GITHUB_REF#refs/tags/}'
19+
20+
- uses: actions/checkout@v2
21+
22+
- uses: actions/[email protected]
23+
name: Setup Haskell Stack
24+
with:
25+
ghc-version: ${{ matrix.ghc }}
26+
stack-version: ${{ matrix.stack }}
27+
28+
- uses: actions/cache@v2
29+
name: Cache ~/.stack
30+
with:
31+
path: ~/.stack
32+
key: ${{ runner.os }}-${{ matrix.ghc }}-v2
33+
34+
- name: Add ~/.local/bin to PATH
35+
run: echo "::add-path::$HOME/.local/bin"
36+
37+
- name: Build
38+
run: make build
39+
id: build
40+
41+
- name: Test
42+
run: make test
43+
44+
- name: Build artifact
45+
if: startsWith(github.ref, 'refs/tags')
46+
run: make artifact
47+
env:
48+
PATAT_TAG: ${{ steps.get_version.outputs.version }}
49+
50+
- uses: actions/upload-artifact@v2
51+
if: startsWith(github.ref, 'refs/tags')
52+
with:
53+
path: artifacts/*
54+
name: artifacts
55+
56+
release:
57+
name: Release
58+
needs: build
59+
runs-on: ubuntu-latest
60+
if: startsWith(github.ref, 'refs/tags')
61+
62+
steps:
63+
- name: Get the version
64+
id: get_version
65+
run: 'echo ::set-output name=version::${GITHUB_REF#refs/tags/}'
66+
67+
- uses: actions/download-artifact@v2
68+
with:
69+
name: artifacts
70+
71+
- name: Display structure of downloaded files
72+
run: ls -R
73+
74+
- uses: actions/create-release@v1
75+
id: create_release
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
with:
79+
tag_name: ${{ steps.get_version.outputs.version }}
80+
release_name: ${{ steps.get_version.outputs.version }}
81+
82+
- name: Upload Linux Asset
83+
uses: actions/upload-release-asset@v1
84+
env:
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+
with:
87+
upload_url: ${{ steps.create_release.outputs.upload_url }}
88+
asset_path: ./stylish-haskell-${{ steps.get_version.outputs.version }}-linux-x86_64.tar.gz
89+
asset_name: stylish-haskell-${{ steps.get_version.outputs.version }}-linux-x86_64.tar.gz
90+
asset_content_type: application/gzip
91+
92+
- name: Upload MacOS Asset
93+
uses: actions/upload-release-asset@v1
94+
env:
95+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96+
with:
97+
upload_url: ${{ steps.create_release.outputs.upload_url }}
98+
asset_path: ./stylish-haskell-${{ steps.get_version.outputs.version }}-darwin-x86_64.zip
99+
asset_name: stylish-haskell-${{ steps.get_version.outputs.version }}-darwin-x86_64.zip
100+
asset_content_type: application/zip

Makefile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
ARCH=$(shell uname -m)
2+
UNAME=$(shell uname | tr 'A-Z' 'a-z')
3+
4+
STYLISH_BINARY=$(HOME)/.local/bin/stylish-haskell
5+
STYLISH_TAG?=v$(shell sed -n 's/^Version: *//p' *.cabal)
6+
STYLISH_PACKAGE=stylish-haskell-$(STYLISH_TAG)-$(UNAME)-$(ARCH)
7+
8+
UPX_VERSION=3.94
9+
UPX_NAME=upx-$(UPX_VERSION)-amd64_$(UNAME)
10+
UPX_BINARY=$(HOME)/.local/bin/upx
11+
12+
ifeq ($(UNAME), darwin)
13+
ARCHIVE=zip
14+
ARCHIVE_CREATE=zip -r
15+
ARCHIVE_EXTRACT=unzip
16+
else
17+
ARCHIVE=tar.gz
18+
ARCHIVE_CREATE=tar czf
19+
ARCHIVE_EXTRACT=tar xvzf
20+
endif
21+
22+
ifeq ($(UNAME), darwin)
23+
COMPRESS_BIN_DEPS=
24+
COMPRESS_BIN=ls
25+
else
26+
COMPRESS_BIN_DEPS=$(UPX_BINARY)
27+
COMPRESS_BIN=upx
28+
endif
29+
30+
STACK=stack --system-ghc
31+
32+
# Default target.
33+
.PHONY: build
34+
build: $(STYLISH_BINARY)
35+
36+
# When we want to do a release.
37+
.PHONY: artifact
38+
artifact: $(STYLISH_PACKAGE).$(ARCHIVE)
39+
mkdir -p artifacts
40+
cp $(STYLISH_PACKAGE).$(ARCHIVE) artifacts/
41+
42+
$(STYLISH_PACKAGE).$(ARCHIVE): $(STYLISH_BINARY) $(COMPRESS_BIN_DEPS)
43+
mkdir -p $(STYLISH_PACKAGE)
44+
cp $(STYLISH_BINARY) $(STYLISH_PACKAGE)/
45+
$(COMPRESS_BIN) $(STYLISH_PACKAGE)/stylish-haskell
46+
cp README.markdown $(STYLISH_PACKAGE)/
47+
cp CHANGELOG $(STYLISH_PACKAGE)/
48+
cp LICENSE $(STYLISH_PACKAGE)/
49+
$(ARCHIVE_CREATE) $(STYLISH_PACKAGE).$(ARCHIVE) $(STYLISH_PACKAGE)
50+
51+
$(STYLISH_BINARY):
52+
$(STACK) build --copy-bins
53+
54+
# UPX is used to compress the resulting binary. We currently don't use this on
55+
# Mac OS.
56+
$(UPX_BINARY):
57+
curl -Lo /tmp/$(UPX_NAME).tar.xz \
58+
https://github.com/upx/upx/releases/download/v$(UPX_VERSION)/$(UPX_NAME).tar.xz
59+
cd /tmp && tar xf $(UPX_NAME).tar.xz
60+
mv /tmp/$(UPX_NAME)/upx $(UPX_BINARY)
61+
upx --version
62+
63+
.PHONY: test
64+
test:
65+
stack build --test

0 commit comments

Comments
 (0)