feat(ci): update release #45
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 | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- "v*" | |
pull_request: | |
branches: | |
- "master" | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version to release' | |
required: true | |
default: 'latest' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
m1cr/netcheck | |
ghcr.io/m1/netcheck | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha | |
- uses: docker/setup-qemu-action@v3 | |
- uses: docker/setup-buildx-action@v3 | |
- if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: login to ghcr | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: linux/amd64,linux/arm64 | |
publish: | |
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- target: x86_64-pc-windows-gnu | |
archive: zip | |
- target: x86_64-unknown-linux-musl | |
archive: tar.gz tar.bz2 tar.xz | |
# @TODO<hello@milescroxford.com> - 2024-03-08: Add support for darwin, | |
# see: https://github.com/rust-build/rust-build.action/issues/88 | |
# | |
# ``` | |
# - target: x86_64-apple-darwin | |
# archive: zip | |
# ``` | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: dtolnay/rust-toolchain@stable | |
- run: | | |
if [ "${GITHUB_REF##*/}" = main ]; then | |
echo "VERSION=latest" >> "$GITHUB_ENV" | |
echo "Setting version to latest" | |
elif [ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]; then | |
echo "VERSION=${{ github.event.inputs.version }}" >> "$GITHUB_ENV" | |
echo "Setting version to ${{ github.event.inputs.version }}" | |
else | |
echo "VERSION=${GITHUB_REF##*/}" >> "$GITHUB_ENV" | |
echo "Setting version to ${GITHUB_REF##*/}" | |
fi | |
- uses: rust-build/rust-build.action@v1.4.5 | |
id: build | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
MINIFY: true | |
RUSTTARGET: ${{ matrix.target }} | |
ARCHIVE_TYPES: ${{ matrix.archive }} | |
ARCHIVE_NAME: netcheck_${{ env.VERSION }} | |
EXTRA_FILES: "README.md LICENSE" | |
STATIC_LINKING: false | |
- uses: azure/setup-helm@v4 | |
with: | |
version: v3.8.0 | |
- run: helm template chart/netcheck --output-dir ./helm-template | |
- run: | | |
zip netcheck-helm-${{ env.VERSION }}.zip -r chart/netcheck | |
zip netcheck-k8s-manifests-${{ env.VERSION }}.zip -r helm-template/netcheck/templates | |
- uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
generate_release_notes: true | |
prerelease: true | |
files: | | |
${{ steps.build.outputs.BUILT_ARCHIVE }} | |
${{ steps.build.outputs.BUILT_CHECKSUM }} | |
netcheck_${{ env.VERSION }}-chart.zip | |
netcheck_${{ env.VERSION }}-k8s-manifest.zip |