Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v2.0.0 | Rewrite #3

Merged
merged 4 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/PULL_REQUEST_TEMPLATE/major_release_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
Release Description
-->

## ❗ Breaking Changes
<!--
- `API.SendRequest` has been rewritten and its parameters have changed
-->

## 🆕 Features
<!--
- Added this
- Added that
- Added feature1
- Added feature2
- Changed feature3
-->

## 🐞 Fixes
<!--
- Fixed this
- Fixed that
- Fixed all of them
-->

## ❗ Breaking Changes
<!--
- `API.SendRequest` has been rewritten and its parameters have changed
- Fixed feature4
- Fixed feature5
-->
10 changes: 5 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE/minor_release_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

## 🆕 Features
<!--
- Added this
- Added that
- Added feature1
- Added feature2
- Changed feature3
-->

## 🐞 Fixes
<!--
- Fixed this
- Fixed that
- Fixed all of them
- Fixed feature4
- Fixed feature5
-->
5 changes: 2 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE/patch_release_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

## 🐞 Fixes
<!--
- Fixed this
- Fixed that
- Fixed all of them
- Fixed feature4
- Fixed feature5
-->
20 changes: 10 additions & 10 deletions .github/PULL_REQUEST_TEMPLATE/prerelease_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
Prerelease Description
-->

## ❗ Breaking Changes
<!--
- `API.SendRequest` has been rewritten and its parameters have changed
-->

## 🆕 Features
<!--
- Added this
- Added that
- Added feature1
- Added feature2
- Changed feature3
-->

## 🐞 Fixes
<!--
- Fixed this
- Fixed that
- Fixed all of them
-->

## ❗ Breaking Changes
<!--
- `API.SendRequest` has been rewritten and its parameters have changed
- Fixed feature4
- Fixed feature5
-->
109 changes: 109 additions & 0 deletions .github/workflows/i.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Synchronize Pointag

on:
workflow_call:

defaults:
run:
shell: bash

jobs:
synchronize-pointag:
runs-on: ubuntu-22.04
if: ${{ (github.event_name != 'push' || startsWith(github.event.ref, 'refs/tags/')) && (github.event_name != 'delete' || github.event.ref_type == 'tag') }}
env:
CONTINUE_JOB: 1
permissions:
contents: write
timeout-minutes: 2

steps:
- name: Extract information
id: extract
env:
EVENT_REF: ${{ github.event.ref }}
IS_PUSH_EVENT: ${{ github.event_name == 'push' }}
IS_MISC_EVENT: ${{ github.event_name != 'push' && github.event_name != 'delete' }}
run: |
if [[ $IS_MISC_EVENT == 'true' ]] ; then
echo '::error::The workflow only supports the on.push and the on.delete triggers.'
exit 1
fi

if [[ $IS_PUSH_EVENT == 'true' ]] ; then
EVENT_REF="${EVENT_REF#refs/tags/}"
fi
if [[ $EVENT_REF == */* ]] ; then
tag_directory="${EVENT_REF%/*}/"
fi

version="${EVENT_REF##*/}"
if [[ $version =~ ^v[0-9]$ ]] ; then
echo '::notice::Refusing to overwrite user-initiated update of a pointag.'
echo 'CONTINUE_JOB=0' >> "$GITHUB_ENV"
exit 0
elif [[ ! $version =~ ^v[0-9]+\.[0-9] ]] ; then
echo '::error::Incorrect version format.'
exit 1
fi

major_pointag="$tag_directory${version%%.*}"
echo "tag-directory=$tag_directory" >> "$GITHUB_OUTPUT"
echo "major-pointag=$major_pointag" >> "$GITHUB_OUTPUT"
echo "major-version=$version" >> "$GITHUB_OUTPUT"

- name: Update or delete pointag
if: ${{ env.CONTINUE_JOB == '1' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IS_DELETE_EVENT: ${{ github.event_name == 'delete' }}

MAJOR_POINTAG: ${{ steps.extract.outputs.major-pointag }}
MAJOR_VERSION: ${{ steps.extract.outputs.major-version }}
TAG_DIRECTORY: ${{ steps.extract.outputs.tag-directory }}

REPOSITORY_URL: ${{ github.server_url }}/${{ github.repository }}.git
run: |
git -c init.defaultBranch=default-branch init
git remote add origin "$REPOSITORY_URL"
git config "http.$REPOSITORY_URL.extraheader" "Authorization: Basic $(echo -n "x-access-token:$GH_TOKEN" | base64 -w0)"

tags_under_major_version="$(git ls-remote --sort=v:refname --tags origin "refs/tags/$MAJOR_POINTAG*")"
major_pointag_information="$(head -1 <<< "$tags_under_major_version")"
highest_tag_information="$(tail -1 <<< "$tags_under_major_version")"
highest_tag_reference="$(cut -s -f 2 <<< "$highest_tag_information")"

if [[ -z $major_pointag_information ]] ; then
if [[ $IS_DELETE_EVENT == 'true' ]] ; then
echo '::notice::User-initated deletion of major pointag.'
exit 0
else
echo "::error::Failed to find any tags under $MAJOR_VERSION."
exit 1
fi
elif [[ $major_pointag_information == $highest_tag_information ]] ; then
if [[ $highest_tag_reference == "refs/tags/$MAJOR_POINTAG" ]] ; then
echo '::notice::Deleting dangling pointag.'
git push -f origin ":refs/tags/$MAJOR_POINTAG" || true
exit 0
else
create_pointag='true'
fi
fi

highest_tag_revision="$(cut -s -f 1 <<< "$highest_tag_information")"

if [[ $create_pointag != 'true' ]] ; then
major_pointag_revision="$(cut -s -f 1 <<< "$major_pointag_information")"
if [[ $major_pointag_revision == $highest_tag_revision ]] ; then
echo "$MAJOR_POINTAG is already pointing at the highest tag under it."
exit 0
fi

echo "Setting $MAJOR_POINTAG to $highest_tag_revision ($highest_tag_reference)."
else
echo "Creating $MAJOR_POINTAG and setting it to $highest_tag_revision ($highest_tag_reference)."
fi

git fetch --depth 1 origin "$highest_tag_revision"
git push -f origin "FETCH_HEAD:refs/tags/$MAJOR_POINTAG"
14 changes: 14 additions & 0 deletions .github/workflows/run-synchronize-pointag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Synchronize Pointag

on:
delete:

push:
tags:
- '**'

jobs:
synchronize-pointag:
permissions:
contents: write
uses: ./.github/workflows/i.yml
16 changes: 0 additions & 16 deletions .github/workflows/run-update-major-tag.yml

This file was deleted.

121 changes: 0 additions & 121 deletions .github/workflows/update-major-tag.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT No Attribution

Copyright 2023 Arthri
Copyright 2023, 2024 Arthryxate

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading