|
10 | 10 | - '.github/ISSUE_TEMPLATE/**' |
11 | 11 | - '.github/PULL_REQUEST_TEMPLATE.md' |
12 | 12 |
|
| 13 | + |
13 | 14 | jobs: |
| 15 | + generate_infos: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + outputs: |
| 18 | + tag: ${{ steps.tag.outputs.version }} |
| 19 | + pr: ${{ steps.tag.outputs.pr }} |
| 20 | + steps: |
| 21 | + - name: Check out the repo |
| 22 | + uses: actions/checkout@v2 |
| 23 | + with: |
| 24 | + ref: main |
| 25 | + fetch-depth: 0 |
| 26 | + - name: Set up awesome-ci |
| 27 | + run: | |
| 28 | + wget https://github.com/eksrvb/awesome-ci/releases/latest/download/awesome-ci |
| 29 | + chmod +x awesome-ci |
| 30 | + - id: tag |
| 31 | + shell: bash |
| 32 | + run: | |
| 33 | + echo "Building version: 0.8.0" |
| 34 | + echo "::set-output name=version::\"0.8.0\"" |
| 35 | +
|
14 | 36 | build: |
15 | 37 | runs-on: ubuntu-latest |
| 38 | + needs: generate_infos |
| 39 | + strategy: |
| 40 | + matrix: |
| 41 | + arch: ["amd64", "arm64"] |
16 | 42 | steps: |
17 | 43 | - name: Checkout code |
18 | 44 | uses: actions/checkout@v2 |
19 | 45 | - name: Set up Go |
20 | 46 | uses: actions/setup-go@v2 |
21 | 47 | with: |
22 | | - go-version: 1.16 |
| 48 | + go-version: 1.17 |
23 | 49 | - name: Set up awesome-ci |
24 | 50 | run: | |
25 | 51 | wget https://github.com/eksrvb/awesome-ci/releases/latest/download/awesome-ci |
26 | 52 | chmod +x awesome-ci |
| 53 | +
|
| 54 | + - name: debugging git |
| 55 | + run: | |
| 56 | + echo "git name-rev HEAD: $(git name-rev HEAD)" |
| 57 | + echo "git log -1 --pretty=format:"%s": $(git log -1 --pretty=format:"%s")" |
| 58 | + echo "git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@': $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')" |
27 | 59 | - name: set build Infos |
28 | 60 | run: ./awesome-ci getBuildInfos |
29 | 61 | env: |
30 | 62 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
31 | | - - name: Build amd64 |
32 | | - run: go build -v -ldflags "-X main.version=$ACI_NEXT_VERSION" -o out/awesome-ci |
| 63 | + |
| 64 | + - name: Build "${{ matrix.arch }}" |
| 65 | + run: go build -v -ldflags "-X main.version=$ACI_NEXT_VERSION" -o out/ |
33 | 66 | env: |
34 | 67 | GOOS: linux |
35 | | - GOARCH: amd64 |
36 | | - - name: Build arm64 |
37 | | - run: go build -v -ldflags "-X main.version=$ACI_NEXT_VERSION" -o out/awesome-ci-arm64 |
| 68 | + GOARCH: "${{ matrix.arch }}" |
| 69 | + |
| 70 | + - name: rename buildable |
| 71 | + working-directory: out |
| 72 | + run: mv awesome-ci awesome-ci_${{ needs.generate_tag.outputs.version }}_${{ matrix.arch }} |
| 73 | + |
| 74 | + - name: Cache build outputs |
| 75 | + uses: actions/cache@v2 |
38 | 76 | env: |
39 | | - GOOS: linux |
40 | | - GOARCH: arm64 |
41 | | - - name: Print version of awesome-ci |
42 | | - run: ./out/awesome-ci -version |
43 | | - - name: Integration testing |
44 | | - run: ./tools/test.sh ./out/awesome-ci |
| 77 | + cache-name: cache-outputs-modules |
| 78 | + with: |
| 79 | + path: out/ |
| 80 | + key: awesome-ci-${{ needs.generate_tag.outputs.version }}-pr-${{ needs.generate_tag.outputs.pr }}-${{ hashFiles('out/awesome-ci*') }} |
| 81 | + restore-keys: | |
| 82 | + awesome-ci-${{ needs.generate_tag.outputs.version }}-pr-${{ needs.generate_tag.outputs.pr }} |
| 83 | +
|
| 84 | + #- name: Integration testing |
| 85 | + # run: ./tools/test.sh ./out/awesome-ci_${ACI_NEXT_VERSION}_${{ matrix.arch }} |
| 86 | + # env: |
| 87 | + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 88 | + |
| 89 | + create_release_test: |
| 90 | + runs-on: ubuntu-latest |
| 91 | + needs: build |
| 92 | + steps: |
| 93 | + - name: Checkout code |
| 94 | + uses: actions/checkout@v2 |
| 95 | + - name: Set up awesome-ci |
| 96 | + run: | |
| 97 | + wget https://github.com/eksrvb/awesome-ci/releases/latest/download/awesome-ci |
| 98 | + chmod +x awesome-ci |
| 99 | +
|
| 100 | + - name: get cache build outputs |
| 101 | + uses: actions/cache@v2 |
45 | 102 | env: |
46 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 103 | + cache-name: cache-outputs-modules |
| 104 | + with: |
| 105 | + path: out/ |
| 106 | + key: awesome-ci-${{ needs.generate_tag.outputs.version }}-pr-${{ needs.generate_tag.outputs.pr }} |
| 107 | + restore-keys: | |
| 108 | + awesome-ci-${{ needs.generate_tag.outputs.version }}-pr-${{ needs.generate_tag.outputs.pr }} |
| 109 | +
|
| 110 | + - name: get generated artifacts |
| 111 | + working-directory: out |
| 112 | + run: ls -la |
| 113 | + |
47 | 114 | - name: Create Release |
48 | | - run: ./out/awesome-ci createRelease -uploadArtifacts "file=out/awesome-ci,file=out/awesome-ci-arm64" |
| 115 | + run: awesome-ci createRelease -uploadArtifacts "file=out/$ARTIFACT1,file=out/$ARTIFACT2" |
49 | 116 | env: |
50 | 117 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 118 | + ARTIFACT1: awesome-ci_${{ needs.generate_tag.outputs.version }}_amd64 |
| 119 | + ARTIFACT2: awesome-ci_${{ needs.generate_tag.outputs.version }}_arm64 |
0 commit comments