Skip to content

Release

Release #21

Workflow file for this run

name: Release
on:
release:
types:
- created
workflow_dispatch:
env:
BUILT_BINARY_PATH: ./
BUILT_BINARY_NAME: derelay
ARCHIVE_FILE_NAME: derelay-latest-linux-amd64
# docker image
REGISTRY: rabbyhub
IMAGE: rabbyhub/derelay
jobs:
make-artifacts:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.19.x
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.RELEASE_APP_ID }}
private_key: ${{ secrets.RELEASE_APP_SECRECT }}
- name: Make binaries
run: |
go build
- name: Set env
run: |
echo "REVISION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
echo "ARCHIVE_FILE_NAME=derelay-${GITHUB_REF/refs\/tags\//}-linux-amd64" >> $GITHUB_ENV
- name: Archive artifacts
run: |
mkdir $ARCHIVE_FILE_NAME
cp $BUILT_BINARY_PATH/$BUILT_BINARY_NAME $ARCHIVE_FILE_NAME/$BUILT_BINARY_NAME
sha256sum $ARCHIVE_FILE_NAME/$BUILT_BINARY_NAME --tag >> $ARCHIVE_FILE_NAME/sha256.checksum
chmod u+x $ARCHIVE_FILE_NAME/$BUILT_BINARY_NAME
tar cvfz $ARCHIVE_FILE_NAME.tar.gz $ARCHIVE_FILE_NAME
- uses: actions/upload-artifact@v3
with:
name: derelay-artifact
path: $ARCHIVE_FILE_NAME.tar.gz
- name: Get release
id: get_release
uses: bruceadams/[email protected]
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
- name: Upload Linux release binary
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: ${{ env.BUILT_BINARY_PATH }}/${{ env.BUILT_BINARY_NAME }}
asset_name: derelay-linux
asset_content_type: application/octet-stream
- name: Upload Linux release binary tarbal
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: ${{ env.ARCHIVE_FILE_NAME }}.tar.gz
asset_name: ${{ env.ARCHIVE_FILE_NAME }}.tar.gz
asset_content_type: application/gzip
make-image:
runs-on: ubuntu-latest
steps:
- name: Checkout dettack
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=raw,value=${{ github.sha }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}