|
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - 'main' |
7 | | - tags: |
8 | | - - 'v*' |
| 7 | +env: |
| 8 | + go-version: 1.16 |
9 | 9 | jobs: |
10 | 10 | build: |
11 | | - name: Build binaries |
| 11 | + name: Build |
12 | 12 | runs-on: ubuntu-20.04 |
13 | 13 | steps: |
14 | | - - uses: actions/checkout@v2 |
15 | | - - uses: actions/setup-go@v2 |
| 14 | + - name: Checkout |
| 15 | + uses: actions/checkout@v2 |
| 16 | + |
| 17 | + - name: Setup golang |
| 18 | + uses: actions/setup-go@v2 |
16 | 19 | with: |
17 | | - go-version: 1.16 |
18 | | - - run: make test |
19 | | - - run: make install GOBIN=/tmp/ |
20 | | - - name: Upload binaries for setup-hw |
21 | | - uses: actions/upload-artifact@v2 |
22 | | - with: |
23 | | - name: setup-hw-binaries |
24 | | - path: | |
25 | | - /tmp/setup-hw |
26 | | - /tmp/monitor-hw |
27 | | - /tmp/collector |
28 | | - /tmp/setup-apply-firmware |
29 | | - retention-days: 1 |
30 | | - build_image: |
31 | | - name: Build images |
32 | | - needs: build |
33 | | - runs-on: ubuntu-20.04 |
34 | | - steps: |
35 | | - - uses: actions/checkout@v2 |
36 | | - - name: Download binaries for setup-hw |
37 | | - uses: actions/download-artifact@v2 |
38 | | - with: |
39 | | - name: setup-hw-binaries |
40 | | - - run: | |
41 | | - cp setup-hw docker |
42 | | - cp monitor-hw docker |
43 | | - cp collector docker |
44 | | - cp setup-apply-firmware docker |
45 | | - - run: | |
| 20 | + go-version: ${{ env.go-version }} |
| 21 | + |
| 22 | + - name: Run test |
| 23 | + run: make test |
| 24 | + |
| 25 | + - name: Build binaries |
| 26 | + run: make install GOBIN=`pwd`/docker |
| 27 | + |
| 28 | + - name: Build setup-hw image |
| 29 | + run: | |
46 | 30 | docker build -t quay.io/cybozu/setup-hw:latest --target stage1 docker |
47 | 31 | docker build -t quay.io/cybozu/setup-hw-secret:latest docker |
48 | | - - run: | |
49 | | - mkdir -p /tmp/docker |
50 | | - docker save quay.io/cybozu/setup-hw:latest -o /tmp/docker/setup-hw-image |
51 | | - docker save quay.io/cybozu/setup-hw-secret:latest -o /tmp/docker/setup-hw-secret-image |
52 | | - - name: Upload setup-hw images |
53 | | - uses: actions/upload-artifact@v2 |
54 | | - with: |
55 | | - name: setup-hw-images |
56 | | - path: | |
57 | | - /tmp/docker/setup-hw-image |
58 | | - /tmp/docker/setup-hw-secret-image |
59 | | - retention-days: 1 |
60 | | - release: |
61 | | - name: Release on GitHub |
62 | | - runs-on: ubuntu-20.04 |
63 | | - needs: build_image |
64 | | - if: startsWith(github.ref, 'refs/tags/v') |
65 | | - steps: |
66 | | - - name: Download setup-hw images |
67 | | - uses: actions/download-artifact@v2 |
68 | | - with: |
69 | | - name: setup-hw-images |
70 | | - - name: Load images |
71 | | - run: | |
72 | | - docker load -i setup-hw-image |
73 | | - docker load -i setup-hw-secret-image |
74 | | - - name: Push images |
75 | | - run: | |
76 | | - echo ${{ secrets.QUAY_PASSWORD }} | docker login -u ${{ secrets.QUAY_USER }} --password-stdin quay.io |
77 | | - TAG=${GITHUB_REF#refs/tags/v} |
78 | | - for name in setup-hw setup-hw-secret; do |
79 | | - echo "pushing ${name}:v${TAG} ..." |
80 | | - docker tag quay.io/cybozu/${name}:latest quay.io/cybozu/${name}:$TAG |
81 | | - docker push quay.io/cybozu/${name}:latest |
82 | | - docker push quay.io/cybozu/${name}:$TAG |
83 | | - done |
84 | | - - name: Create release |
85 | | - id: create_release |
86 | | - uses: actions/create-release@v1 |
87 | | - env: |
88 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
89 | | - with: |
90 | | - tag_name: ${{ github.ref }} |
91 | | - release_name: Release ${{ github.ref }} |
92 | | - body: | |
93 | | - See [CHANGELOG.md](./CHANGELOG.md) for details. |
94 | | - draft: false |
95 | | - prerelease: ${{ contains(github.ref, '-') }} |
0 commit comments