Skip to content

GitHub release

GitHub release #3

Workflow file for this run

---
# stolen from https://github.com/laluka/bypass-url-parser/blob/main/.github/workflows/release.yml thx @laluka <3
name: GitHub release
on:
workflow_dispatch:
inputs:
tag:
description: "The version to tag, without the leading 'v'. If omitted, will initiate a dry run (no uploads)."
type: string
major_version:
type: choice
description: The major version to update
options:
- v1
default: "v1"
sha:
description: "The full sha of the commit to be released. If omitted, the latest commit on the default branch will be used."
default: ""
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha }}
- name: Set local tag for version
if: ${{ inputs.tag }}
run: |
# Set to Github Actor
git config user.email "${{ github.actor }}@users.noreply.github.com"
git config user.name "${{ github.actor }} (GitHub Actions)"
git tag -m "v${{ inputs.tag }}" "v${{ inputs.tag }}"
git tag -f -m ${{ inputs.major_version }} ${{ inputs.major_version }}
- name: Build the Docker image
run: docker build . --file Dockerfile --tag ${{ github.repository }}:$(date +%s)
validate-tag:
name: Validate tag
runs-on: ubuntu-latest
# If you don't set an input tag, it's a dry run (no uploads).
if: ${{ inputs.tag }}
steps:
- uses: actions/checkout@v4
with:
ref: main # We checkout the main branch to check for the commit
- name: Check main branch
if: ${{ inputs.sha }}
run: |
# Fetch the main branch since a shallow checkout is used by default
git fetch origin main --unshallow
if ! git branch --contains ${{ inputs.sha }} | grep -E '(^|\s)main$'; then
echo "The specified sha is not on the main branch" >&2
exit 1
fi
tag-release:
name: Tag release
runs-on: ubuntu-latest
needs: build
# If you don't set an input tag, it's a dry run (no uploads).
if: ${{ inputs.tag }}
permissions:
# For git tag
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha }}
- name: git tag
run: |
git config user.email "${{ github.actor }}@users.noreply.github.com"
git config user.name "${{ github.actor }} (GitHub Actions)"
git tag -m "v${{ inputs.tag }}" "v${{ inputs.tag }}"
git tag -f -m ${{ inputs.major_version }} ${{ inputs.major_version }}
git push --tags
publish-release:
name: Publish to GitHub
runs-on: ubuntu-latest
needs: tag-release
# If you don't set an input tag, it's a dry run (no uploads).
if: ${{ inputs.tag }}
permissions:
# For GitHub release publishing
contents: write
steps:
- name: "Publish to GitHub"
uses: softprops/action-gh-release@v2
with:
draft: true
tag_name: v${{ inputs.tag }}