diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 0e9ae9f..f3f9d1e 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -5,6 +5,8 @@ on: push: paths: - 'tex/**' + tags: + - '*' pull_request: paths: - 'tex/**' @@ -43,3 +45,53 @@ jobs: with: name: resume-pdf path: out/${{ env.PDF_NAME }} + + release: + needs: build + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + + steps: + - name: ๐Ÿ“ฅ Checkout repository + uses: actions/checkout@v2 + + - name: ๐Ÿ“ Install LaTeX + run: | + sudo apt-get update + sudo apt-get install -y texlive-full latexmk + + - name: ๐Ÿ“ฆ Install dependencies + run: | + python -m pip install --upgrade pip + cd lib && pip install -r requirements.txt + + - name: ๐Ÿ“„ Generate PDF + run: make + + - name: ๐Ÿ“ค Upload release asset + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: out/${{ env.PDF_NAME }} + asset_name: ${{ env.PDF_NAME }} + asset_content_type: application/pdf + + - name: ๐Ÿ“„ Create GitHub Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + body: "Generated CV PDF for release ${{ github.ref }}" + draft: true + prerelease: false + + - name: ๐Ÿ“ค Upload PDF to Release + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: out/${{ env.PDF_NAME }} + asset_name: ${{ env.PDF_NAME }} + asset_content_type: application/pdf diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 0000000..955ffe0 --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,80 @@ +name: Create and Push Tag + +on: + workflow_dispatch: + inputs: + tag: + description: 'Tag to create (e.g. 4.2.0)' + required: false + default: '' + description: + description: 'Tag description' + required: false + default: '' + +jobs: + create_tag: + runs-on: ubuntu-latest + steps: + - name: ๐Ÿ›Ž๏ธ Checkout Repository + uses: actions/checkout@v2 + + - name: ๐Ÿงช Get Current Tag + id: get_current_tag + run: | + CURRENT_TAG=$(git describe --tags --abbrev=0) + echo "CURRENT_TAG=$CURRENT_TAG" >> $GITHUB_ENV + echo "Current tag is $CURRENT_TAG" + + - name: ๐Ÿ“ Determine New Tag + id: determine_new_tag + run: | + INPUT_TAG=${{ github.event.inputs.tag }} + if [ -z "$INPUT_TAG" ]; then + MAJOR=$(echo $CURRENT_TAG | cut -d. -f1) + MINOR=$(echo $CURRENT_TAG | cut -d. -f2) + PATCH=$(echo $CURRENT_TAG | cut -d. -f3) + NEW_TAG="$MAJOR.$((MINOR+1)).0" + else + NEW_TAG=$INPUT_TAG + fi + echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV + echo "New tag is $NEW_TAG" + + - name: โš ๏ธ Check Tag Validity + id: check_tag_validity + run: | + CURRENT_TAG=${{ env.CURRENT_TAG }} + NEW_TAG=${{ env.NEW_TAG }} + if [ $(echo -e "$CURRENT_TAG\n$NEW_TAG" | sort -V | head -n1) = "$NEW_TAG" ] && [ "$CURRENT_TAG" != "$NEW_TAG" ]; then + echo "::warning::The new tag $NEW_TAG is lower than the current tag $CURRENT_TAG" + fi + + - name: ๐Ÿ”‘ Set Up Git User + run: | + git config user.name "Liss-Bot" + git config user.email "liss-bot@d0h.co" + + - name: ๐Ÿ“ฆ Create New Tag + id: create_new_tag + run: | + NEW_TAG=${{ env.NEW_TAG }} + DESCRIPTION=${{ github.event.inputs.description }} + git tag -a $NEW_TAG -m "$DESCRIPTION" + git push origin $NEW_TAG + + - name: ๐Ÿš€ Push New Tag + if: ${{ secrets.BOT_TOKEN }} + run: | + NEW_TAG=${{ env.NEW_TAG }} + git push origin $NEW_TAG + env: + GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} + + - name: ๐Ÿš€ Push New Tag (Fallback) + if: ${{ !secrets.BOT_TOKEN }} + run: | + NEW_TAG=${{ env.NEW_TAG }} + git push origin $NEW_TAG + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}