Release #51
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: "Release" | |
permissions: | |
contents: "write" | |
packages: "write" | |
on: | |
workflow_run: | |
workflows: [ "Tag" ] | |
types: [ completed ] | |
branches: | |
- 'main' | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
get-tag: | |
name: "Get Tag From Package Version" | |
runs-on: "ubuntu-latest" | |
outputs: | |
pkg-version: ${{ steps.pkg-version.outputs.PKG_VERSION }} | |
steps: | |
- name: "Check out the repo" | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Get tag" | |
id: "pkg-version" | |
shell: "bash" | |
run: | | |
echo PKG_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/["]/, "", $2); printf("%s",$2) }' Cargo.toml) >> $GITHUB_OUTPUT | |
create-release: | |
name: "Create release" | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
needs: "get-tag" | |
runs-on: "ubuntu-latest" | |
steps: | |
- name: "Check out the repo" | |
uses: actions/checkout@v3 | |
- name: "Create release" | |
uses: "taiki-e/create-gh-release-action@v1" | |
with: | |
# (optional) Path to changelog. | |
changelog: CHANGELOG.md | |
branch: "main" | |
ref: refs/tags/v${{ needs.get-tag.outputs.pkg-version }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
upload-assets: | |
name: "Upload assets to Github releases" | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
needs: | |
- "get-tag" | |
- "create-release" | |
strategy: | |
matrix: | |
include: | |
- target: "x86_64-unknown-linux-gnu" | |
os: "ubuntu-latest" | |
- target: "x86_64-unknown-linux-musl" | |
os: "ubuntu-latest" | |
- target: "aarch64-unknown-linux-gnu" | |
os: "ubuntu-latest" | |
- target: "aarch64-apple-darwin" | |
os: "macos-latest" | |
- target: "x86_64-apple-darwin" | |
os: "macos-latest" | |
- target: "universal-apple-darwin" | |
os: "macos-latest" | |
- target: "x86_64-pc-windows-gnu" | |
os: "windows-latest" | |
- target: "x86_64-pc-windows-msvc" | |
os: "windows-latest" | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: "Check out the repo" | |
uses: actions/checkout@v3 | |
- name: "Upload Binaries" | |
uses: "taiki-e/upload-rust-binary-action@v1" | |
with: | |
bin: "rsb" | |
target: ${{ matrix.target }} | |
archive: $bin-${{ matrix.target }} | |
ref: refs/tags/v${{ needs.get-tag.outputs.pkg-version }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
push-to-registry: | |
name: "Push Docker image" | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
needs: | |
- "get-tag" | |
runs-on: "ubuntu-latest" | |
steps: | |
- name: "Check out the repo" | |
uses: actions/checkout@v3 | |
- name: "Set up QEMU" | |
uses: docker/setup-qemu-action@v2 | |
- name: "Set up Docker Buildx" | |
uses: docker/setup-buildx-action@v2 | |
with: | |
driver: docker-container | |
- name: "Login to Docker Hub" | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: "Log in to the github container registry" | |
uses: "docker/login-action@v2" | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Extract metadata (tags, labels) for Docker" | |
id: "meta" | |
uses: "docker/metadata-action@v4" | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: "Build and push Docker image" | |
uses: "docker/build-push-action@v4" | |
with: | |
context: . | |
push: true | |
file: docker/Dockerfile | |
tags: | | |
gamelife1314/rsb:latest | |
gamelife1314/rsb:v${{ needs.get-tag.outputs.pkg-version }} | |
ghcr.io/gamelife1314/rsb:latest | |
ghcr.io/gamelife1314/rsb:v${{ needs.get-tag.outputs.pkg-version }} | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: linux/amd64,linux/arm64/v8 | |
build-args: | | |
BUILDKIT_MULTI_PLATFORM=1 |