aboutsummaryrefslogtreecommitdiffhomepage
path: root/.circleci/build.yml
blob: e3e0073f64fc6becda3cb8e0af418828e4d28860 (plain)
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
version: 2.1

# Passed from config.yml
parameters:
  skip:
    type: boolean
    default: true

defaults: &defaults
  resource_class: large
  docker:
    - image: bepsays/ci-hugoreleaser:1.22300.20000
environment: &buildenv
  GOMODCACHE: /root/project/gomodcache
jobs:
  prepare_release:
    <<: *defaults
    environment: &buildenv
      GOMODCACHE: /root/project/gomodcache
    steps:
      - &remote-docker
        setup_remote_docker:
          version: 20.10.14
      - checkout:
          path: hugo
      - &git-config
        run:
          command: |
            git config --global user.email "bjorn.erik.pedersen+hugoreleaser@gmail.com"
            git config --global user.name "hugoreleaser"
      - run:
          command: |
            cd hugo
            go mod download
            go run -tags release main.go release --step 1
      - save_cache:
          key: git-sha-{{ .Revision }}
          paths:
            - hugo
            - gomodcache
  build_container1:
    <<: [*defaults]
    environment:
      <<: [*buildenv]
    steps:
      - &restore-cache
        restore_cache:
          key: git-sha-{{ .Revision }}
      - run:
          no_output_timeout: 20m
          command: |
            mkdir -p /tmp/files/dist1
            cd hugo
            hugoreleaser build -paths "builds/container1/**" -workers 3 -dist /tmp/files/dist1 -chunks $CIRCLE_NODE_TOTAL -chunk-index $CIRCLE_NODE_INDEX
      - &persist-workspace
        persist_to_workspace:
          root: /tmp/files
          paths:
            - dist1
            - dist2
    parallelism: 7
  build_container2:
    <<: [*defaults]
    environment:
      <<: [*buildenv]
    docker:
      - image: bepsays/ci-hugoreleaser-linux-arm64:1.22300.20000
    steps:
      - *restore-cache
      - &attach-workspace
        attach_workspace:
          at: /tmp/workspace
      - run:
          command: |
            mkdir -p /tmp/files/dist2
            cd hugo
            hugoreleaser build -paths "builds/container2/**" -workers 1 -dist /tmp/files/dist2
      - *persist-workspace
  archive_and_release:
    <<: [*defaults]
    environment:
      <<: [*buildenv]
    steps:
      - *restore-cache
      - *attach-workspace
      - *git-config
      - run:
          name: Add github.com to known hosts
          command: ssh-keyscan github.com >> ~/.ssh/known_hosts
      - run:
          command: |
            cp -a /tmp/workspace/dist1/. ./hugo/dist
            cp -a /tmp/workspace/dist2/. ./hugo/dist
      - run:
          command: |
            cd hugo
            hugoreleaser archive
            hugoreleaser release
            go run -tags release main.go release --step 2
workflows:
  release:
    when:
      and:
        - equal: [false, << pipeline.parameters.skip >>]
    jobs:
      - prepare_release:
          filters:
            branches:
              only: /release-.*/
      - build_container1:
          requires:
            - prepare_release
      - build_container2:
          requires:
            - prepare_release
      - archive_and_release:
          context: org-global
          requires:
            - build_container1
            - build_container2