release and publish #11
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 and publish | |
on: | |
workflow_dispatch: | |
inputs: | |
bump_level: | |
description: "The bump level of this release" | |
required: true | |
type: choice | |
options: | |
- alpha | |
- beta | |
- rc | |
- release | |
- patch | |
- minor | |
- major | |
overwrite_version: | |
description: "Overwrite the version for this release" | |
required: false | |
type: string | |
env: | |
REGISTRY: "ghcr.io" | |
IMAGE_NAME: "${{ github.repository }}" | |
jobs: | |
release: | |
environment: release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
# - name: load gpg key used to sign commits | |
# uses: crazy-max/ghaction-import-gpg@v5 | |
# with: | |
# gpg_private_key: ${{ secrets.PGP_SIGNING_SUBKEY }} | |
# git_user_signingkey: true | |
# fingerprint: 97846C8651A44F47 | |
# git_commit_gpgsign: true | |
# git_tag_gpgsign: true | |
# # not supported by github | |
# git_push_gpgsign: false | |
# - name: install git-cliff | |
# uses: baptiste0928/cargo-install@v1 | |
# with: | |
# crate: git-cliff | |
# version: latest | |
- name: set git author | |
run: | | |
git config --local user.name 'Github Action' | |
git config --local user.email action@github.com | |
- name: install cargo-release | |
uses: baptiste0928/cargo-install@v1 | |
with: | |
crate: cargo-release | |
version: latest | |
- name: run cargo-release | |
run: | | |
OVERWRITE=${{ inputs.overwrite_version }} | |
BUMP_LEVEL=${OVERWRITE:-${{ inputs.bump_level}}} | |
cargo release --verbose --execute --no-publish --no-confirm --workspace $BUMP_LEVEL | |
- name: extract version | |
run: | | |
echo VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select( .name=="secret2pgp-server" ) | .version') >> $GITHUB_ENV | |
- name: setup docker buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: setup metadata | |
uses: docker/metadata-action@v4 | |
id: metadata | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
images: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" | |
tags: | | |
type=semver,pattern={{version}},value=${{ env.VERSION }} | |
- name: log in to GHCR | |
uses: docker/login-action@v1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: build docker image and push | |
uses: docker/build-push-action@v3 | |
with: | |
context: "." | |
push: true | |
tags: "${{ steps.metadata.outputs.tags }}" | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |