-
Notifications
You must be signed in to change notification settings - Fork 1
128 lines (127 loc) · 5.14 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Build and Test
on:
push:
branches: [ master ]
pull_request:
type: [ synchronize ]
jobs:
build:
name: build and test
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'ci skip')"
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-24.11
extra_nix_config: |
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
substituters = https://cache.iog.io https://hydra.iohk.io https://cache.nixos.org/
- uses: cachix/cachix-action@v14
with:
name: jcouyang
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Test
run: nix-shell --run 'cabal update && cabal test'
- run: |
VERSION=$(nix-shell -p dhall --run 'dhall text < ./version.dhall')
echo publishing $VERSION lib...
env VER=$VERSION nix-shell -p gnused --run 'sed -i "s/0.1.0.0/${VER}/" ./dhall-secret.cabal'
- name: cabal tar
run: |
nix-shell --run 'cabal sdist'
- name: docker tar
run: |
dockertar=$(nix-build docker.nix)
cp $dockertar ./docker-image-dhall-secret.tar.gz
- uses: actions/upload-artifact@v4
with:
name: tars
path: |
./dist-newstyle/sdist/
./docker-image-dhall-secret.tar.gz
binary:
strategy:
matrix:
os:
- runner: "macos-latest"
build-script: "nix-build -A dhall-secret.components.exes.dhall-secret"
- runner: "ubuntu-latest"
build-script: "nix-build -A projectCross.musl64.hsPkgs.dhall-secret.components.exes.dhall-secret"
name: binary on ${{ matrix.os.runner }}
runs-on: ${{ matrix.os.runner }}
if: "!contains(github.event.head_commit.message, 'ci skip')"
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-24.11
extra_nix_config: |
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
substituters = https://cache.iog.io https://hydra.iohk.io https://cache.nixos.org/
- uses: cachix/cachix-action@v14
with:
name: jcouyang
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: |
VERSION=$(nix-shell -p dhall --run 'dhall text < ./version.dhall')
echo publishing $VERSION lib...
env VER=$VERSION nix-shell -p gnused --run 'sed -i "s/0.1.0.0/${VER}/" ./dhall-secret.cabal'
- name: Static Binary
run: ${{matrix.os.build-script}}
- uses: actions/upload-artifact@v4
with:
name: ${{matrix.os.runner}}-binary
path: ./result/bin/dhall-secret
publish:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'publish skip') && (github.ref == 'refs/heads/master')"
needs:
- build
- binary
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v4
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-24.11
extra_nix_config: |
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
substituters = https://cache.iog.io https://hydra.iohk.io https://cache.nixos.org/
- uses: cachix/cachix-action@v14
with:
name: jcouyang
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: upload to hackage
env:
HACKAGE_PASS: ${{ secrets.HACKAGE_PASS }}
run: |
export VERSION=$(nix-shell -p dhall --run 'dhall text < ./version.dhall')
env VER=$VERSION nix-shell -p gnused --run 'sed -i "s/0.1.0.0/${VER}/" ./dhall-secret.cabal'
nix-shell --run 'cabal update && cabal upload -u oyanglulu -p "$HACKAGE_PASS" ./tars/dist-newstyle/sdist/dhall-secret-$VERSION.tar.gz'
nix-shell --run 'cabal upload -d -u oyanglulu -p "$HACKAGE_PASS"'
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: package docker
run: |
VERSION=$(nix-shell -p dhall --run 'dhall text < ./version.dhall')
docker load < ./tars/docker-image-dhall-secret.tar.gz
docker tag ghcr.io/jcouyang/dhall-secret:latest ghcr.io/jcouyang/dhall-secret:$VERSION
docker push ghcr.io/jcouyang/dhall-secret:latest
docker push ghcr.io/jcouyang/dhall-secret:$VERSION
- name: tag release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=$(nix-shell -p dhall --run 'dhall text < ./version.dhall')
echo publishing $VERSION binary...
mv ubuntu-latest-binary/dhall-secret dhall-secret-x86_64-linux
mv macos-latest-binary/dhall-secret dhall-secret-x86_64-macOS
gh release create "v$VERSION" ./dhall-secret-x86_64-linux ./dhall-secret-x86_64-macOS