-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2735822
commit 24fda38
Showing
11 changed files
with
499 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: 2 | ||
updates: | ||
- directory: / | ||
package-ecosystem: gitsubmodule | ||
schedule: | ||
interval: daily | ||
- directory: / | ||
package-ecosystem: github-actions | ||
schedule: | ||
interval: daily |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Automatic pre-release | ||
|
||
on: | ||
push: | ||
tags: ["v*-*"] | ||
|
||
jobs: | ||
auto_pre_release: | ||
name: Automatic pre-release | ||
permissions: | ||
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
# NOTE: | ||
# Some automatic release action | ||
# might need history for generate change log. | ||
fetch-depth: 0 | ||
|
||
- name: Run generate-release-assets.sh | ||
id: generate_release_assets | ||
run: | | ||
# NOTE: | ||
# The pitchfork layout holds extra scripts in tools directory. | ||
# > https://blog.black-desk.cn/pages/pintchfork-layout.html | ||
# But the "Standard Go Project Layout" | ||
# holds extra scripts in scripts directory. | ||
# > https://github.com/golang-standards/project-layout#scripts | ||
generate_release_assets=tools/generate-release-assets.sh | ||
if [ ! -f "$generate_release_assets" ]; then | ||
generate_release_assets=scripts/generate-release-assets.sh | ||
fi | ||
if [ ! -f "$generate_release_assets" ]; then | ||
echo "generate-release-assets script not found" >&2 | ||
exit -1 | ||
fi | ||
ASSETS="$("${generate_release_assets}")" | ||
echo assets="$ASSETS" >> $GITHUB_OUTPUT | ||
- name: Run marvinpinto/action-automatic-releases | ||
uses: marvinpinto/action-automatic-releases@latest | ||
if: needs.auto_tag.outputs.new_tag | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
automatic_release_tag: ${{ needs.auto_tag.outputs.new_tag }} | ||
prerelease: true | ||
files: ${{ steps.generate_release_assets.outputs.assets }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
name: Automatic create tag and release. | ||
on: | ||
push: | ||
branches: [master] | ||
|
||
jobs: | ||
auto_tag: | ||
permissions: | ||
contents: write | ||
name: Automatic create new tag from tools/get_project_version.sh | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
# NOTE: | ||
# Step `check_tag` need history. | ||
fetch-depth: 0 | ||
|
||
- name: Run get-project-version.sh | ||
id: get_project_version | ||
run: | | ||
# NOTE: | ||
# The pitchfork layout holds extra scripts in tools directory. | ||
# > https://blog.black-desk.cn/pages/pintchfork-layout.html | ||
# But the "Standard Go Project Layout" | ||
# holds extra scripts in scripts directory. | ||
# > https://github.com/golang-standards/project-layout#scripts | ||
get_project_version=tools/get-project-version.sh | ||
if [ ! -f "$get_project_version" ]; then | ||
get_project_version=scripts/get-project-version.sh | ||
fi | ||
if [ ! -f "$get_project_version" ]; then | ||
echo "get-project-version script not found" >&2 | ||
exit -1 | ||
fi | ||
version="$("${get_project_version}")" | ||
echo version="$version" >> $GITHUB_OUTPUT | ||
- name: Check if tag already exists | ||
id: check_tag | ||
run: | | ||
if git rev-parse "${{ steps.get_project_version.outputs.version }}" &>/dev/null; then | ||
echo existed=true >> $GITHUB_OUTPUT | ||
else | ||
echo existed=false >> $GITHUB_OUTPUT | ||
fi | ||
- name: Run anothrNick/github-tag-action | ||
id: create_tag | ||
if: steps.check_tag.outputs.existed == 'false' | ||
uses: anothrNick/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}} | ||
CUSTOM_TAG: ${{ steps.get_project_version.outputs.version }} | ||
|
||
outputs: | ||
new_tag: ${{ steps.create_tag.outputs.new_tag }} | ||
|
||
auto_release: | ||
permissions: | ||
contents: write | ||
name: Automatic release for new tag | ||
runs-on: ubuntu-latest | ||
needs: | ||
- auto_tag | ||
steps: | ||
- name: Checkout repository | ||
if: needs.auto_tag.outputs.new_tag | ||
uses: actions/checkout@v4 | ||
with: | ||
# NOTE: | ||
# Some automatic release action | ||
# might need history for generate change log. | ||
fetch-depth: 0 | ||
|
||
- name: Run tools/generate-release-assets.sh | ||
id: generate_release_assets | ||
if: needs.auto_tag.outputs.new_tag | ||
run: | | ||
# NOTE: | ||
# The pitchfork layout holds extra scripts in tools directory. | ||
# > https://blog.black-desk.cn/pages/pintchfork-layout.html | ||
# But the "Standard Go Project Layout" | ||
# holds extra scripts in scripts directory. | ||
# > https://github.com/golang-standards/project-layout#scripts | ||
generate_release_assets=tools/generate-release-assets.sh | ||
if [ ! -f "$generate_release_assets" ]; then | ||
generate_release_assets=scripts/generate-release-assets.sh | ||
fi | ||
if [ ! -f "$generate_release_assets" ]; then | ||
echo "generate-release-assets script not found" >&2 | ||
exit -1 | ||
fi | ||
ASSETS="$("${generate_release_assets}")" | ||
echo assets="$ASSETS" >> $GITHUB_OUTPUT | ||
- name: Run marvinpinto/action-automatic-releases | ||
uses: marvinpinto/action-automatic-releases@latest | ||
if: needs.auto_tag.outputs.new_tag | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
automatic_release_tag: ${{ needs.auto_tag.outputs.new_tag }} | ||
prerelease: false | ||
files: ${{ steps.generate_release_assets.outputs.assets }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Checks | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
checks: | ||
name: Run black-desk/checks | ||
permissions: | ||
checks: write | ||
contents: read | ||
issues: write | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: black-desk/checks@master | ||
pass: | ||
name: Pass | ||
if: always() | ||
needs: | ||
- checks | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Decide whether the needed jobs succeeded or failed | ||
uses: re-actors/alls-green@release/v1 | ||
with: | ||
jobs: ${{ toJSON(needs) }} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
// The single header file version of the errors library. | ||
|
||
#define ERRORS_SINGLE_HEADER_FILE | ||
|
||
@ERRORS_CONFIG_HEADER_FILE@ | ||
@ERRORS_VERSION_HEADER_FILE@ | ||
@ERRORS_SOURCE_LOCATION_HEADER_FILE@ | ||
@ERRORS_ERROR_HEADER_FILE@ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#!/usr/bin/env bash | ||
# NOTE: | ||
# Use /usr/bin/env to find shell interpreter for better portability. | ||
# Reference: https://en.wikipedia.org/wiki/Shebang_%28Unix%29#Portability | ||
|
||
# NOTE: | ||
# Exit immediately if any commands (even in pipeline) | ||
# exits with a non-zero status. | ||
set -e | ||
set -o pipefail | ||
|
||
# WARNING: | ||
# This is not reliable when using POSIX sh | ||
# and current script file is sourced by `source` or `.` | ||
CURRENT_SOURCE_FILE_PATH="${BASH_SOURCE[0]:-$0}" | ||
CURRENT_SOURCE_FILE_NAME="$(basename -- "$CURRENT_SOURCE_FILE_PATH")" | ||
|
||
# This function log messages to stderr works like printf | ||
# with a prefix of the current script name. | ||
# Arguments: | ||
# $1 - The format string. | ||
# $@ - Arguments to the format string, just like printf. | ||
function log() { | ||
local format="$1" | ||
shift | ||
# shellcheck disable=SC2059 | ||
printf "$CURRENT_SOURCE_FILE_NAME: $format\n" "$@" >&2 || true | ||
} | ||
|
||
# shellcheck disable=SC2016 | ||
USAGE="$CURRENT_SOURCE_FILE_NAME"' | ||
This script generate release assets | ||
then print paths to the generated assets to STDOUT. | ||
You can use this script in github action like this: | ||
```yaml | ||
name: Example workflow | ||
on: | ||
push: | ||
tags: * | ||
jobs: | ||
auto_release: | ||
name: Automatic release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Run tools/'"$CURRENT_SOURCE_FILE_NAME"' | ||
id: generate_release_assets | ||
run: | | ||
ASSETS=$(tools/'"$CURRENT_SOURCE_FILE_NAME"') | ||
echo assets="$ASSETS" >> $GITHUB_OUTPUT | ||
- name: Automatic release | ||
uses: marvinpinto/action-automatic-releases@latest | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
prerelease: false | ||
files: ${{ steps.generate_release_assets.outputs.assets }} | ||
``` | ||
'" | ||
Usage: | ||
$CURRENT_SOURCE_FILE_NAME -h | ||
$CURRENT_SOURCE_FILE_NAME | ||
Options: | ||
-h Show this screen." | ||
|
||
while getopts ':h' option; do | ||
case "$option" in | ||
h) | ||
echo "$USAGE" | ||
exit | ||
;; | ||
\?) | ||
log "[ERROR] Unknown option: -%s" "$OPTARG" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
shift $((OPTIND - 1)) | ||
|
||
CURRENT_SOURCE_FILE_DIR="$(dirname -- "$CURRENT_SOURCE_FILE_PATH")" | ||
cd -- "$CURRENT_SOURCE_FILE_DIR" | ||
|
||
source ./utils.sh | ||
|
||
# ------------------------------------------------------------------------------ | ||
|
||
check_ci | ||
|
||
BUILD_DIR="../build_generate-release-assets" | ||
|
||
configure_cmake_project .. $BUILD_DIR -DCMAKE_BUILD_TYPE=Release >&2 | ||
|
||
realpath "$BUILD_DIR"/errors.hpp |
Oops, something went wrong.