on master help sign in
Redid whole CI
commit35e210e1b6f814ca243906afba7fe48200ec0f23 authoriko <ilyakooo0@gmail.com> dateFri 22 Oct 2021, 14:39 (5 years ago) parent74b2133
5 files changed+158−84
.github/actions/common_setup/action.yaml+46 .github/actions/push_docker_images/action.yaml+26 .github/workflows/github-actions-image.yaml+82−28 .github/workflows/linux-binary.yaml−54 default.nix+4−2
.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:
55 branches: [master]
66 pull_request:
77 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
817
918jobs:
1019 build-github-action-image:
@@ -14,43 +23,88 @@ jobs:
1423 - uses: actions/checkout@v2
1524 with:
1625 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
1833 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
2036
21− sudo swapoff /mnt/swapfile
22− sudo fallocate -l 12G /mnt/swapfile
23− sudo mkswap /mnt/swapfile
24− sudo swapon /mnt/swapfile
37+ - name: Build Linux static binary
38+ run: |
39+ mkdir compaREST-binary
40+ cp (nix-build -A compaRESTBin -j auto) -o compaREST-binary/compaREST
2541
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
2747
28− - name: Install Nix
29− uses: cachix/install-nix-action@v12
48+ - name: Upload compaREST Image
49+ uses: actions/upload-artifact@v2
3050 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/
51+ name: compaREST-image
52+ path: compaREST-image.tar.gz
3453
35− - name: Login to Cachix
36− uses: cachix/cachix-action@v8
54+ - name: Upload compaREST Linux Binary
55+ uses: actions/upload-artifact@v2
3756 with:
38− name: octopod
39− signingKey: ${{ secrets.CACHIX_SIGNING_KEY }}
57+ name: compaREST-linux
58+ path: compaREST-binary/compaREST
4059
41− - name: Build Github Action Docker Image
42− run: |
43− nix-build -A compaRESTGithubAction -j auto -o image
60+ - name: Push Nightly Docker Images to DockerHub
61+ if: github.ref == 'refs/heads/master' && github.event_name == 'push'
62+ uses: ./.github/actions/push_docker_images
63+ with:
64+ tag: nightly
65+ docker_username: ${{ secrets.DOCKERHUB_USERNAME }}
66+ docker_password: ${{ secrets.DOCKERHUB_TOKEN }}
4467
45− - name: Log into Docker Hub
46− if: github.ref == 'refs/heads/master'
47− uses: docker/login-action@v1
68+ release:
69+ name: Release
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
4882 with:
49− username: ${{ secrets.DOCKER_HUB_USERNAME }}
50− password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
83+ tag: ${{ github.event.inputs.version }}
84+ docker_username: ${{ secrets.DOCKERHUB_USERNAME }}
85+ docker_password: ${{ secrets.DOCKERHUB_TOKEN }}
5186
52− - name: Upload Image to Docker Hub
53− if: github.ref == 'refs/heads/master'
87+ - name: Push Docker latest Images to DockerHub
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
5496 run: |
55− docker load -i image
56− docker push typeable/comparest-github-action:latest
97+ chmod +x compaREST-linux/compaREST
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
4545 ${pkgs.nukeReferences}/bin/nuke-refs $out/bin/*
4646 '';
4747
48+ compaRESTBin = hsPkgs.projectCross.musl64.hsPkgs.comparest.components.exes.comparest;
49+
4850 compaREST = pkgs.dockerTools.buildImage {
4951 name = "compaREST";
50− contents = [ (staticify "compaREST-static" hsPkgs.projectCross.musl64.hsPkgs.comparest.components.exes.comparest) ];
52+ contents = [ (staticify "compaREST-static" compaRESTBin) ];
5153 config = {
5254 Entrypoint = [ "/bin/comparest" ];
5355 };
@@ -68,4 +70,4 @@ let
6870 };
6971
7072in
71−{ inherit compaREST compaRESTGithubAction hsPkgs haskellNix; }
73+{ inherit compaREST compaRESTGithubAction hsPkgs haskellNix compaRESTBin; }