|
| 1 | +name: release |
| 2 | +#触发机制,当创建tag时 |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: |
| 6 | + - published |
| 7 | +jobs: |
| 8 | + frontend-builder: |
| 9 | + name: frontend-builder |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: SetOutput |
| 13 | + id: vars |
| 14 | + run: echo "tag=${GITHUB_REF#refs/*/v}" >> $GITHUB_OUTPUT |
| 15 | + - name: Checkout #Checkout代码 |
| 16 | + uses: actions/checkout@v3 |
| 17 | + - name: Set up Node |
| 18 | + uses: actions/setup-node@v3.0.0 |
| 19 | + with: |
| 20 | + node-version: '18.12' |
| 21 | + - name: Pnpm install and build |
| 22 | + run: | |
| 23 | + npm install -g pnpm |
| 24 | + pnpm install --registry https://registry.npmmirror.com --dir ./frontend |
| 25 | + echo "Build frontend..." |
| 26 | + cd ./frontend && pnpm run build |
| 27 | + - name: upload frontend release |
| 28 | + uses: actions/upload-artifact@v2 |
| 29 | + with: |
| 30 | + name: frontend-package |
| 31 | + path: frontend/dist |
| 32 | + release: |
| 33 | + needs: [frontend-builder] |
| 34 | + name: release |
| 35 | + runs-on: ubuntu-latest |
| 36 | + steps: |
| 37 | + - name: SetOutput #处理Tag字符串并存进outputs |
| 38 | + id: vars |
| 39 | + run: | |
| 40 | + echo "tag=${GITHUB_REF#refs/*/v}" >> $GITHUB_OUTPUT |
| 41 | + - name: Checkout #Checkout代码 |
| 42 | + uses: actions/checkout@v3 |
| 43 | + - name: download frontend release |
| 44 | + uses: actions/download-artifact@v2 |
| 45 | + with: |
| 46 | + name: frontend-package |
| 47 | + path: frontend/dist |
| 48 | + - name: Set up Go |
| 49 | + uses: actions/setup-go@v3 |
| 50 | + with: |
| 51 | + go-version: '1.21.1' |
| 52 | + - name: Go tidy |
| 53 | + run: | |
| 54 | + go mod tidy |
| 55 | + echo "GOVERSION=$(go version)" >> $GITHUB_ENV |
| 56 | + - name: Create archives on Release #创建各种系统架构下的二进制包并上传至release assets |
| 57 | + uses: goreleaser/goreleaser-action@v3.1.0 |
| 58 | + with: |
| 59 | + version: 1.9.2 |
| 60 | + args: release --rm-dist |
| 61 | + env: |
| 62 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + docker-push: |
| 64 | + needs: [frontend-builder] |
| 65 | + name: docker-push |
| 66 | + runs-on: ubuntu-latest |
| 67 | + steps: |
| 68 | + - name: SetOutput |
| 69 | + id: vars |
| 70 | + run: echo "tag=${GITHUB_REF#refs/*/v}" >> $GITHUB_OUTPUT |
| 71 | + - uses: actions/checkout@v3 |
| 72 | + |
| 73 | + - name: download frontend release |
| 74 | + uses: actions/download-artifact@v2 |
| 75 | + with: |
| 76 | + name: frontend-package |
| 77 | + path: frontend/dist |
| 78 | + - name: Login Docker #登录docker |
| 79 | + uses: docker/login-action@v1 |
| 80 | + with: |
| 81 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 82 | + password: ${{ secrets.DOCKER_TOKEN }} |
| 83 | + |
| 84 | + - name: build |
| 85 | + run: cd scripts && ./docker_publish.sh ${{ secrets.DOCKER_USERNAME }} "backend" |
| 86 | + |
0 commit comments