Skip to content

v0.4.0: add jq-backed --json output for read and write commands #7

v0.4.0: add jq-backed --json output for read and write commands

v0.4.0: add jq-backed --json output for read and write commands #7

Workflow file for this run

name: Release
on:
push:
branches: ["master"]
permissions:
contents: write
concurrency:
group: release-master
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Determine version
id: ver
shell: bash
run: |
set -Eeuo pipefail
chmod +x ./rtunnel
VERSION="$(bash ./rtunnel --version)"
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version string from ./rtunnel --version: '$VERSION'" >&2
exit 1
fi
TAG="v${VERSION}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
- name: Check if tag already exists
id: tagcheck
shell: bash
run: |
set -Eeuo pipefail
TAG="${{ steps.ver.outputs.tag }}"
if git rev-parse -q --verify "refs/tags/${TAG}" >/dev/null; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "Tag ${TAG} already exists. No release will be created."
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "Tag ${TAG} does not exist. Will create release."
fi
- name: Create annotated tag
if: steps.tagcheck.outputs.exists == 'false'
shell: bash
run: |
set -Eeuo pipefail
TAG="${{ steps.ver.outputs.tag }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "$TAG" -m "Release $TAG"
git push origin "$TAG"
- name: Build release assets
if: steps.tagcheck.outputs.exists == 'false'
shell: bash
run: |
set -Eeuo pipefail
chmod +x ./rtunnel ./install.sh
rm -rf dist
mkdir -p dist
cp ./rtunnel ./install.sh dist/
cp ./config/rtunnel.env.example dist/rtunnel.env.example
(
cd dist
sha256sum rtunnel install.sh rtunnel.env.example > SHA256SUMS
)
- name: Create GitHub Release and upload assets
if: steps.tagcheck.outputs.exists == 'false'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
set -Eeuo pipefail
TAG="${{ steps.ver.outputs.tag }}"
gh release create "$TAG" \
--title "$TAG" \
--notes "Automated release for $TAG" \
dist/rtunnel dist/install.sh dist/rtunnel.env.example dist/SHA256SUMS