v0.15.6 #55
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: packAndDockerImages | |
#触发机制,当main分支有创建tag时 | |
on: | |
release: | |
types: | |
- published | |
jobs: | |
releasePackage: | |
name: releaseOnGithub | |
runs-on: ubuntu-latest | |
steps: | |
- name: SetOutput #处理Tag字符串并存进outputs | |
id: vars | |
run: | | |
echo "tag=${GITHUB_REF#refs/*/v}" >> $GITHUB_OUTPUT | |
- name: SetUpGo | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '1.21.1' | |
- name: Checkout #Checkout代码 | |
uses: actions/checkout@v3 | |
- name: GoTidy | |
run: | | |
go mod tidy | |
echo "GOVERSION=$(go version)" >> $GITHUB_ENV | |
echo "EoscVersion=$(sed -n 's/.*eosc v/v/p' go.mod)" >> $GITHUB_ENV | |
- name: Create archives on Release #创建各种系统架构下的二进制包并上传至release assets | |
uses: goreleaser/[email protected] | |
with: | |
version: latest | |
args: release --rm-dist | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
dockerImage: | |
needs: [releasePackage] | |
name: buildDockerImage | |
runs-on: ubuntu-latest | |
steps: | |
- name: SetupGo | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '1.21.1' | |
- uses: actions/checkout@v3 | |
- name: SetOutput | |
id: vars | |
run: echo "tag=${GITHUB_REF#refs/*/v}" >> $GITHUB_OUTPUT | |
- name: GoTidy | |
run: | | |
go mod tidy | |
- name: Pack #运行打包脚本并且将生成的tar包复制至Dockerfile所在目录 | |
run: | | |
./build/cmd/package.sh ${{ steps.vars.outputs.tag }} | |
cp ./out/apinto-${{ steps.vars.outputs.tag }}.linux.x64.tar.gz ./build/resources/apinto.linux.x64.tar.gz | |
- name: Login Docker #登录docker | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: buildImage | |
run: | | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/apinto-gateway:${{ steps.vars.outputs.tag }} -f ./build/resources/Dockerfile ./build/resources | |
- name: pushImage | |
run: | | |
docker push ${{ secrets.DOCKER_USERNAME }}/apinto-gateway:${{ steps.vars.outputs.tag }} | |
docker tag ${{ secrets.DOCKER_USERNAME }}/apinto-gateway:${{ steps.vars.outputs.tag }} ${{ secrets.DOCKER_USERNAME }}/apinto-gateway:latest | |
docker push ${{ secrets.DOCKER_USERNAME }}/apinto-gateway:latest |