mirror of
https://github.com/eiblog/eiblog.git
synced 2026-03-01 00:34:58 +08:00
chore: github actions
This commit is contained in:
71
.github/workflows/release.yml
vendored
71
.github/workflows/release.yml
vendored
@@ -3,65 +3,84 @@ name: release image & asset
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- "v*"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
package:
|
package:
|
||||||
runs-on: ubuntu-16.04
|
runs-on: ubuntu-16.04
|
||||||
steps:
|
steps:
|
||||||
- name: step0
|
- name: Golang env
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: ^1.15
|
go-version: ^1.15
|
||||||
- name: step1
|
- name: Checkout
|
||||||
run: go mod download && ./dist.sh
|
uses: actions/checkout@v2
|
||||||
- name: step2
|
- name: Cache mod
|
||||||
uses: azure/docker-login@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
login-server: registry.cn-hangzhou.aliyuncs.com
|
path: ~/go/pkg/mod
|
||||||
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-
|
||||||
|
- name: Docker tag
|
||||||
|
id: vars
|
||||||
|
run: echo ::set-output name=tag::$(echo ${GITHUB_REF:10})
|
||||||
|
- name: Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
- name: Docker login
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: registry.cn-hangzhou.aliyuncs.com
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
- name: step3
|
- name: Build binary
|
||||||
run: |
|
run: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build
|
||||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build \
|
- name: Build and push
|
||||||
&& docker build -t registry.cn-hangzhou.aliyuncs.com/deepzz/eiblog . \
|
uses: docker/build-push-action@v2
|
||||||
&& docker push registry.cn-hangzhou.aliyuncs.com/deepzz/eiblog \
|
with:
|
||||||
&& docker tag registry.cn-hangzhou.aliyuncs.com/deepzz/eiblog registry.cn-hangzhou.aliyuncs.com/deepzz/eiblog:${{ github.ref }} \
|
context: .
|
||||||
&& docker push registry.cn-hangzhou.aliyuncs.com/deepzz/eiblog:${{ github.ref }}
|
file: ./Dockerfile
|
||||||
- name: step4
|
push: true
|
||||||
|
tags: |
|
||||||
|
registry.cn-hangzhou.aliyuncs.com/deepzz/eiblog:latest
|
||||||
|
registry.cn-hangzhou.aliyuncs.com/deepzz/eiblog:${{ steps.vars.outputs.tag }}
|
||||||
|
|
||||||
|
- name: Package tar
|
||||||
|
run: ./dist.sh
|
||||||
|
- name: Create release
|
||||||
id: create_release
|
id: create_release
|
||||||
uses: actions/create-release@v1
|
uses: actions/create-release@v1
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ github.ref }}
|
tag_name: ${{ steps.vars.outputs.tag }}
|
||||||
release_name: Release ${{ github.ref }}
|
release_name: Release ${{ steps.vars.outputs.tag }}
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
- name: step5
|
- name: Upload asset darwin
|
||||||
uses: actions/upload-release-asset@v1
|
uses: actions/upload-release-asset@v1
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
asset_path: eiblog-${{ github.ref }}.darwin-amd64.tar.gz
|
asset_path: eiblog-${{ steps.vars.outputs.tag }}.darwin-amd64.tar.gz
|
||||||
asset_name: eiblog-${{ github.ref }}.darwin-amd64.tar.gz
|
asset_name: eiblog-${{ steps.vars.outputs.tag }}.darwin-amd64.tar.gz
|
||||||
asset_content_type: application/gzip
|
asset_content_type: application/gzip
|
||||||
- name: step6
|
- name: Upload asset linux
|
||||||
uses: actions/upload-release-asset@v1
|
uses: actions/upload-release-asset@v1
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
asset_path: eiblog-${{ github.ref }}.linux-amd64.tar.gz
|
asset_path: eiblog-${{ steps.vars.outputs.tag }}.linux-amd64.tar.gz
|
||||||
asset_name: eiblog-${{ github.ref }}.linux-amd64.tar.gz
|
asset_name: eiblog-${{ steps.vars.outputs.tag }}.linux-amd64.tar.gz
|
||||||
asset_content_type: application/gzip
|
asset_content_type: application/gzip
|
||||||
- name: step7
|
- name: Upload asset windows
|
||||||
uses: actions/upload-release-asset@v1
|
uses: actions/upload-release-asset@v1
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
asset_path: eiblog-${{ github.ref }}.windows-amd64.tar.gz
|
asset_path: eiblog-${{ steps.vars.outputs.tag }}.windows-amd64.tar.gz
|
||||||
asset_name: eiblog-${{ github.ref }}.windows-amd64.tar.gz
|
asset_name: eiblog-${{ steps.vars.outputs.tag }}.windows-amd64.tar.gz
|
||||||
asset_content_type: application/gzip
|
asset_content_type: application/gzip
|
||||||
|
|||||||
Reference in New Issue
Block a user