Skip to content

Commit

Permalink
feat: move to all encompassing CI rather than depending on github to …
Browse files Browse the repository at this point in the history
…schedule on tag push
  • Loading branch information
iwishiwasaneagle committed Nov 7, 2023
1 parent f62a731 commit 263b024
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 64 deletions.
44 changes: 0 additions & 44 deletions .github/workflows/create-tag.yml

This file was deleted.

72 changes: 52 additions & 20 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,63 @@
name: Publish
name: Create tag

on:
workflow_dispatch:
push:
tags:
- "*"
schedule:
# * is a special character in YAML so you have to quote this string
- cron: "0 0 * * *"

jobs:
setup-envs:
name: Generate data for release
runs-on: ubuntu-20.04
if:
create-tag:
name: Create tag if new commit
runs-on: ubuntu-latest
outputs:
release_body: ${{ steps.release.outputs.release_body }}
tag-name: ${{ steps.create-tag-name.outputs.tag }}
skip: ${{ steps.skip.outputs.skip }}
tag: ${{ steps.create-tag-name.outputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Should it run?
id: skip
run: |
PREVTAGCOMMIT="$(git tag --sort=creatordate | tail -n1 | awk -F'-' '{print $4}')"
CURRENTCOMMIT="$(git rev-parse --short HEAD)"
if [ "$PREVTAGCOMMIT" == "$CURRENTCOMMIT" ]; then
echo "Tags are the same ($PREVTAGCOMMIT != $CURRENTCOMMIT), skipping future steps"
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "Tags are not the same ($PREVTAGCOMMIT != $CURRENTCOMMIT). Continuing."
echo "skip=false" >> $GITHUB_OUTPUT
fi
- name: Set tag
id: create-tag-name
if: steps.skip.outputs.skip == 'false'
run: |
v=${GITHUB_REF##*/}
echo "Version: $v"
echo "::set-output name=tag::$v"
echo "tag=$(date '+%F')-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Tag commit
if: steps.skip.outputs.skip == 'false' && !env.ACT
uses: tvdias/[email protected]
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
tag: ${{ steps.create-tag-name.outputs.tag }}

setup-envs:
name: Generate data for release
runs-on: ubuntu-latest
needs: create-tag
if: needs.create-tag.outputs.skip == 'false'
outputs:
release_body: ${{ steps.release.outputs.release_body }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Generate latest changelog
uses: orhun/git-cliff-action@v2
Expand All @@ -44,12 +76,12 @@ jobs:
r="$(printf "$r" | tail -n +3)"
r="${r//'%'/'%25'}"
r="${r//$'\n'/'%0A'}"
r="${r//$'\r'/'%0D'}"
echo "::set-output name=release_body::$r"
r="${r//$'\r'/ &&
build:
name: Build document
runs-on: ubuntu-latest
needs: [create-tag, setup-envs]
if: needs.create-tag.outputs.skip == 'false'
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -79,9 +111,9 @@ jobs:

publish-github:
name: Publish on GitHub
needs: [setup-envs, build]
runs-on: ubuntu-20.04

runs-on: ubuntu-latest
needs: [create-tag, setup-envs, build]
if: needs.create-tag.outputs.skip == 'false' && !env.ACT
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -99,5 +131,5 @@ jobs:
tag: ${{ github.ref }}
file: ${{steps.download.outputs.download-path}}/main.pdf
asset_name: $tag.pdf
release_name: "${{needs.setup-envs.outputs.tag-name}}"
release_name: "${{ needs.create-tag.outputs.tag }}"
body: "${{ needs.setup-envs.outputs.release_body }}"

0 comments on commit 263b024

Please sign in to comment.