Skip to content

Commit

Permalink
Create release-image.yml
Browse files Browse the repository at this point in the history
CI
  • Loading branch information
liray-unendlich authored Jul 1, 2021
1 parent cb246f4 commit a0a950d
Showing 1 changed file with 139 additions and 0 deletions.
139 changes: 139 additions & 0 deletions .github/workflows/release-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Release Go Project/Release ghcr image

on:
push:
tags: v*

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v2
with:
go-version: 1.16

- name: Check out code into Go module dir
uses: actions/checkout@v2

- name: Get dependencies
run: go get -v -t -d ./...

- name: Test code
run: go test -v .

setup-release:
name: Setup release
needs: test
runs-on: ubuntu-latest
steps:
- name: Create release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
tag_name: ${{github.ref}}
release_name: Release ${{github.ref}}
draft: false
prerelease: false

- name: Get url to upload the release
env:
url: ${{ steps.create_release.outputs.upload_url }}
run: |
mkdir artifact
echo $url > artifact/url.txt
- name: Upload artifact to share url with jobs
uses: actions/upload-artifact@v1
with:
name: artifact
path: artifact/url.txt

release-pkg:
name: Release package
needs: setup-release
runs-on: ubuntu-latest
strategy:
matrix:
os: [mac64, lin64, win64]
include:
- os: mac64
goos: darwin
arch: amd64
- os: lin64
goos: linux
arch: amd64
- os: win64
goos: windows
arch: amd64
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v2
with:
go-version: 1.16

- name: Check out code into go module dir
uses: actions/checkout@v2

- name: Get dependencies
run: go get -v -t -d ./...

- name: Build
env:
goos: ${{matrix.goos}}
goarch: ${{matrix.arch}}
run: |
mkdir dist
GOOS=$goos GOARCH=$goarch go build -v -o dist/app .
zip -j -r release dist
- name: Download artifact to get url to upload
uses: actions/download-artifact@v1
with:
name: artifact

- name: Get url from artifact
id: get_url
run: |
url=$(cat artifact/url.txt)
echo "##[set-output name=upload_url;]$url"
- name: Upload release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.get_url.outputs.upload_url}}
asset_path: release.zip
asset_name: release-${{matrix.os}}.zip
asset_content_type: application/zip

docker_build_push:
runs-on: ubuntu-latest
env:
IMAGE_NAME: concordium-exporter
steps:
- name: Checkout code into dir
uses: actions/checkout@v2

- name: Setup docker buildx
uses: docker/setup-buildx-action@v1

- name: Login to Github Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.repository_owner}}
password: ${{secrets.GHCR_TOKEN}}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
ghcr.io/${{github.repository_owner}}/${{env.IMAGE_NAME}}:latest
ghcr.io/${{github.repository_owner}}/${{env.IMAGE_NAME}}:${{github.sha}}

0 comments on commit a0a950d

Please sign in to comment.