|
1 | 1 | name: Create release |
2 | 2 |
|
3 | | -on: |
4 | | - push: |
5 | | - branches: |
6 | | - - main |
7 | | - |
8 | | -permissions: |
9 | | - contents: write |
10 | | - pull-requests: write |
| 3 | +on: workflow_dispatch |
11 | 4 |
|
12 | 5 | jobs: |
13 | 6 | build: |
14 | | - strategy: |
15 | | - matrix: |
16 | | - runs-on: [ubuntu-latest, macos-latest] |
17 | | - runs-on: ${{ matrix.runs-on }} |
18 | | - name: Build |
19 | | - steps: |
20 | | - - name: Set up Go 1.x |
21 | | - uses: actions/setup-go@v3 |
22 | | - with: |
23 | | - go-version: 1.20.7 |
24 | | - id: go |
25 | | - |
26 | | - - name: Check out code into the Go module directory |
27 | | - uses: actions/checkout@v3 |
28 | | - with: |
29 | | - fetch-depth: "0" |
30 | | - |
31 | | - - name: Get dependencies |
32 | | - run: | |
33 | | - go get -v -t -d ./... |
34 | | - if [ -f Gopkg.toml ]; then |
35 | | - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh |
36 | | - dep ensure |
37 | | - fi |
38 | | -
|
39 | | - # https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable |
40 | | - - name: Set environment variables |
41 | | - run: | |
42 | | - APP_VER_SHORT=$(git describe --tags) |
43 | | - GOOS=$(go env GOOS) |
44 | | - GOARCH=$(go env GOARCH) |
45 | | - GOPATH=$(go env GOPATH) |
46 | | - ARCHIVE="kc_eth_bridge""$APP_VER_SHORT""_""$GOOS""_""$GOARCH"".tgz" |
47 | | - BUILD_DIR=${GITHUB_WORKSPACE}/build |
48 | | -
|
49 | | - echo "GOOS=${GOOS}" >> $GITHUB_ENV |
50 | | - echo "GOARCH=${GOARCH}" >> $GITHUB_ENV |
51 | | - echo "ARCHIVE=${ARCHIVE}" >> $GITHUB_ENV |
52 | | - echo "BUILD_DIR=${BUILD_DIR}" >> $GITHUB_ENV |
53 | | -
|
54 | | - - name: Build |
55 | | - run: | |
56 | | - mkdir -p ${BUILD_DIR} |
57 | | - cd ${GITHUB_WORKSPACE}/cmd/bridge && go build -o "${BUILD_DIR}/" -a -i -ldflags="-X main.appVersion=${APP_VER}" |
58 | | -
|
59 | | - - name: Package |
60 | | - run: | |
61 | | - cd ${GITHUB_WORKSPACE} |
62 | | -
|
63 | | - cd ${BUILD_DIR} |
64 | | - tar czvf "${GITHUB_WORKSPACE}/${ARCHIVE}" * |
65 | | - stat ${GITHUB_WORKSPACE}/${ARCHIVE} |
66 | | -
|
67 | | - - name: Save artifacts |
68 | | - uses: actions/upload-artifact@v3 |
69 | | - with: |
70 | | - name: ${{ env.ARCHIVE }} |
71 | | - path: ${{ github.workspace }}/${{ env.ARCHIVE }} |
72 | | - if-no-files-found: error |
73 | | - |
74 | | - release: |
75 | | - needs: [build] |
76 | | - runs-on: ubuntu-latest |
77 | | - steps: |
78 | | - - name: Check out code |
79 | | - uses: actions/checkout@v3 |
80 | | - |
81 | | - # https://docs.github.com/en/free-pro-team@latest/actions/guides/storing-workflow-data-as-artifacts#downloading-or-deleting-artifacts |
82 | | - # A directory for each artifact is created using its name |
83 | | - - name: Download all workflow run artifacts |
84 | | - uses: actions/download-artifact@v3 |
85 | | - with: |
86 | | - path: assets |
87 | | - |
88 | | - - name: Display structure of downloaded files |
89 | | - run: ls -R |
90 | | - working-directory: assets |
91 | | - |
92 | | - - name: Create release |
93 | | - env: |
94 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
95 | | - run: | |
96 | | - hub release create --draft --message="Release draft from Github Actions" vNext |
97 | | - for i in $(find ./assets -name '*.tgz' -type f); do |
98 | | - hub release edit --attach=${i} --message="" vNext |
99 | | - done |
| 7 | + uses: klever-io/workflow-calls/.github/workflows/docker.yaml@master |
| 8 | + with: |
| 9 | + flavor: "golang" |
| 10 | + use_default_dockerfiles: false |
| 11 | + secrets: |
| 12 | + gcp_project_id: ${{ secrets.GCP_PROJECT_ID }} |
| 13 | + gcp_cloud_run_sa: ${{ secrets.GCP_CLOUD_RUN_SA }} |
0 commit comments