on master help sign in
Redid whole CI
35e210eiko
.github/actions/common_setup/action.yamlnew file+46
@@ -0,0 +1,46 @@
1+name: "Common setup"
2+description: "Common setup steps"
3+inputs:
4+ cachixSigningKey:
5+ description: "Cachix signing key"
6+ required: true
7+runs:
8+ using: "composite"
9+ steps:
10+ - name: Install skopeo
11+ shell: bash
12+ run: |
13+ sudo apt-get -y update
14+ sudo apt-get -y install skopeo
15+
16+ - name: Increase swap
17+ shell: bash
18+ run: |
19+ free -h
20+
21+ sudo swapoff /mnt/swapfile
22+ sudo fallocate -l 12G /mnt/swapfile
23+ sudo mkswap /mnt/swapfile
24+ sudo swapon /mnt/swapfile
25+
26+ free -h
27+
28+ - name: Install Nix
29+ uses: cachix/install-nix-action@v12
30+ with:
31+ extra_nix_config: |
32+ trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
33+ substituters = https://hydra.iohk.io https://cache.nixos.org/
34+
35+ - name: Login to Cachix
36+ uses: cachix/cachix-action@v8
37+ with:
38+ name: octopod
39+ signingKey: ${{ inputs.cachixSigningKey }}
40+
41+ - name: Allow kvm in Nix
42+ shell: bash
43+ run: |
44+ # enable required features (see https://github.com/cachix/install-nix-action/issues/19)
45+ mkdir -p ~/.config/nix
46+ echo "system-features = kvm" >> ~/.config/nix/nix.conf
.github/actions/push_docker_images/action.yamlnew file+26
@@ -0,0 +1,26 @@
1+name: "Push Docker Images"
2+description: "Push Docker Images"
3+inputs:
4+ tag:
5+ description: "The docker image tag to push."
6+ required: true
7+ docker_username:
8+ description: "The Docker Hub username"
9+ required: true
10+ docker_password:
11+ description: "The Docker Hub password"
12+ required: true
13+runs:
14+ using: "composite"
15+ steps:
16+ - name: Login to DockerHub
17+ uses: docker/login-action@v1.10.0
18+ with:
19+ username: ${{ inputs.docker_username }}
20+ password: ${{ inputs.docker_password }}
21+
22+ - name: Push Docker Images to DockerHub
23+ shell: bash
24+ run: |
25+ skopeo copy docker-archive:$(nix-build -A compaRESTGithubAction -j auto) docker://typeable/comparest-github-action:${{ inputs.tag }}
26+ skopeo copy docker-archive:$(nix-build -A compaREST -j auto) docker://typeable/comparest:${{ inputs.tag }}
.github/workflows/github-actions-image.yaml+82−28
@@ -5,6 +5,15 @@ on:
5 branches: [master]
5 branches: [master]
6 pull_request:
6 pull_request:
7 branches: [master]
7 branches: [master]
8+ workflow_dispatch:
9+ inputs:
10+ release:
11+ description: Release the new version?
12+ required: false
13+ default: "true"
14+ version:
15+ description: The version to release
16+ required: true
8
17
9jobs:
18jobs:
10 build-github-action-image:
19 build-github-action-image:
@@ -14,43 +23,88 @@ jobs:
14 - uses: actions/checkout@v2
23 - uses: actions/checkout@v2
15 with:
24 with:
16 submodules: recursive
25 submodules: recursive
17− - name: Increase swap
26+
27+ - name: Common setup
28+ uses: ./.github/actions/common_setup
29+ with:
30+ cachixSigningKey: ${{ secrets.CACHIX_SIGNING_KEY }}
31+
32+ - name: Build Github Action Docker Image
18 run: |
33 run: |
19− free -h
34+ cp $(nix-build -A compaRESTGithubAction -j auto) compaREST-Github-Action-image.tar.gz
35+ cp $(nix-build -A compaREST -j auto) compaREST-image.tar.gz
20
36
21− sudo swapoff /mnt/swapfile
37+ - name: Build Linux static binary
22− sudo fallocate -l 12G /mnt/swapfile
38+ run: |
23− sudo mkswap /mnt/swapfile
39+ mkdir compaREST-binary
24− sudo swapon /mnt/swapfile
40+ cp (nix-build -A compaRESTBin -j auto) -o compaREST-binary/compaREST
25
41
26− free -h
42+ - name: Upload compaREST Github Action Image
43+ uses: actions/upload-artifact@v2
44+ with:
45+ name: compaREST-Github-Action-image
46+ path: compaREST-Github-Action-image.tar.gz
27
47
28− - name: Install Nix
48+ - name: Upload compaREST Image
29− uses: cachix/install-nix-action@v12
49+ uses: actions/upload-artifact@v2
30 with:
50 with:
31− extra_nix_config: |
51+ name: compaREST-image
32− trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
52+ path: compaREST-image.tar.gz
33− substituters = https://hydra.iohk.io https://cache.nixos.org/
34
53
35− - name: Login to Cachix
54+ - name: Upload compaREST Linux Binary
36− uses: cachix/cachix-action@v8
55+ uses: actions/upload-artifact@v2
37 with:
56 with:
38− name: octopod
57+ name: compaREST-linux
39− signingKey: ${{ secrets.CACHIX_SIGNING_KEY }}
58+ path: compaREST-binary/compaREST
40
59
41− - name: Build Github Action Docker Image
60+ - name: Push Nightly Docker Images to DockerHub
42− run: |
61+ if: github.ref == 'refs/heads/master' && github.event_name == 'push'
43− nix-build -A compaRESTGithubAction -j auto -o image
62+ uses: ./.github/actions/push_docker_images
63+ with:
64+ tag: nightly
65+ docker_username: ${{ secrets.DOCKERHUB_USERNAME }}
66+ docker_password: ${{ secrets.DOCKERHUB_TOKEN }}
44
67
45− - name: Log into Docker Hub
68+ release:
46− if: github.ref == 'refs/heads/master'
69+ name: Release
47− uses: docker/login-action@v1
70+ if: github.event_name == 'workflow_dispatch' && github.event.inputs.release == 'true'
71+ needs: [build-github-action-image]
72+ runs-on: "ubuntu-latest"
73+ steps:
74+ - uses: actions/checkout@v2
75+ - name: Common setup
76+ uses: ./.github/actions/common_setup
77+ with:
78+ cachixSigningKey: ${{ secrets.CACHIX_SIGNING_KEY }}
79+
80+ - name: Push Docker Release Images to DockerHub
81+ uses: ./.github/actions/push_docker_images
48 with:
82 with:
49− username: ${{ secrets.DOCKER_HUB_USERNAME }}
83+ tag: ${{ github.event.inputs.version }}
50− password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
84+ docker_username: ${{ secrets.DOCKERHUB_USERNAME }}
85+ docker_password: ${{ secrets.DOCKERHUB_TOKEN }}
51
86
52− - name: Upload Image to Docker Hub
87+ - name: Push Docker latest Images to DockerHub
53− if: github.ref == 'refs/heads/master'
88+ uses: ./.github/actions/push_docker_images
89+ with:
90+ tag: latest
91+ docker_username: ${{ secrets.DOCKERHUB_USERNAME }}
92+ docker_password: ${{ secrets.DOCKERHUB_TOKEN }}
93+
94+ - uses: actions/download-artifact@v2
95+ - name: Zip and move
54 run: |
96 run: |
55− docker load -i image
97+ chmod +x compaREST-linux/compaREST
56− docker push typeable/comparest-github-action:latest
98+ zip compaREST-linux compaREST-linux/compaREST
99+
100+ mv compaREST-Github-Action-image/* .
101+ mv compaREST-image/* .
102+ - uses: "marvinpinto/action-automatic-releases@latest"
103+ with:
104+ repo_token: "${{ secrets.GITHUB_TOKEN }}"
105+ automatic_release_tag: "latest"
106+ prerelease: false
107+ title: "${{ github.event.inputs.version }}"
108+ files: |
109+ *.zip
110+ *.tar.gz
.github/workflows/linux-binary.yamldeleted−54
@@ -1,54 +0,0 @@
1−name: Linux binary
2−
3−on:
4− push:
5− branches: [master]
6− pull_request:
7− branches: [master]
8−
9−jobs:
10− linux-build:
11− runs-on: ubuntu-latest
12−
13− steps:
14− - uses: actions/checkout@v2
15− with:
16− submodules: recursive
17− - name: Cache
18− uses: actions/cache@v1
19− with:
20− path: ~/.stack
21− key: ${{ runner.os }}-build-stack-${{ hashFiles('**/stack.yaml') }}-${{ hashFiles('**/*.cabal') }}
22− restore-keys: |
23− ${{ runner.os }}-build-stack-${{ hashFiles('**/stack.yaml') }}
24− ${{ runner.os }}-build-stack-
25− - name: Increase swap
26− run: |
27− free -h
28−
29− sudo swapoff /mnt/swapfile
30− sudo fallocate -l 13G /mnt/swapfile
31− sudo mkswap /mnt/swapfile
32− sudo swapon /mnt/swapfile
33−
34− free -h
35−
36− - name: Build
37− run: |
38− stack build --ghc-options=-O3 --local-bin-path comparest-linux --copy-bins --flag comparest:Static
39− - name: Test
40− run: stack test --ghc-options=-O3 --flag comparest:Static --test-arguments='--hide-successes --no-create'
41−
42− - name: Zip
43− if: github.ref == 'refs/heads/master'
44− run: |
45− zip comparest-linux comparest-linux/comparest
46− - uses: "marvinpinto/action-automatic-releases@latest"
47− if: github.ref == 'refs/heads/master'
48− with:
49− repo_token: "${{ secrets.GITHUB_TOKEN }}"
50− automatic_release_tag: "latest"
51− prerelease: false
52− title: "Pre-Release"
53− files: |
54− *.zip
default.nix+4−2
@@ -45,9 +45,11 @@ let
45 ${pkgs.nukeReferences}/bin/nuke-refs $out/bin/*
45 ${pkgs.nukeReferences}/bin/nuke-refs $out/bin/*
46 '';
46 '';
47
47
48+ compaRESTBin = hsPkgs.projectCross.musl64.hsPkgs.comparest.components.exes.comparest;
49+
48 compaREST = pkgs.dockerTools.buildImage {
50 compaREST = pkgs.dockerTools.buildImage {
49 name = "compaREST";
51 name = "compaREST";
50− contents = [ (staticify "compaREST-static" hsPkgs.projectCross.musl64.hsPkgs.comparest.components.exes.comparest) ];
52+ contents = [ (staticify "compaREST-static" compaRESTBin) ];
51 config = {
53 config = {
52 Entrypoint = [ "/bin/comparest" ];
54 Entrypoint = [ "/bin/comparest" ];
53 };
55 };
@@ -68,4 +70,4 @@ let
68 };
70 };
69
71
70in
72in
71−{ inherit compaREST compaRESTGithubAction hsPkgs haskellNix; }
73+{ inherit compaREST compaRESTGithubAction hsPkgs haskellNix compaRESTBin; }