Skip to content

Commit

Permalink
Merge pull request #139 from ineshbose/feature/126-setup_release_system
Browse files Browse the repository at this point in the history
Release system automation
  • Loading branch information
ineshbose committed Apr 8, 2022
2 parents 634ec4d + 70c605a commit e51951a
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 38 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-dissertation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ jobs:
uses: xu-cheng/latex-action@v2
with:
root_file: l4proj.tex
latexmk_shell_escape: true
working_directory: dissertation
extra_system_packages: "inkscape"
- name: Rename PDF
run: |
mv dissertation/l4proj.pdf "Inesh Bose - Portion Mate.pdf"
Expand Down
93 changes: 93 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Create release

on:
push:
branches:
- "master"

jobs:
create_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get PRs
id: merged-prs
uses: actions/github-script@v6
env:
BASE: develop
HEAD: master
with:
result-encoding: string
script: |
const { BASE, HEAD } = process.env;
const { data: { created_at: date } } = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
}).catch(async () => {
const { data: { created_at } } = await github.rest.repos.get({
owner: context.repo.owner,
repo: context.repo.repo,
});
return { data: { created_at } };
});
const { data: pulls } = await github.rest.search.issuesAndPullRequests({
q: `repo:${context.repo.owner}/${context.repo.repo} is:pr base:${BASE} -head:${HEAD} is:merged merged:>${date}`,
per_page: 100
});
const list = pulls.items.map((pull) => {
const detail = `#${pull.number} ${pull.title}`;
if (pull.body) {
const matches = pull.body.match("Closes (.*)\n");
if (matches && matches.length > 1) {
return `${detail} (${matches[1]})`
}
}
return detail;
});
return list.join('\n');
- name: Get SHA
id: sha-substr
uses: actions/github-script@v6
with:
result-encoding: string
script: return context.sha.substring(0, 7);
- name: Zip source
working-directory: src
run: |
zip ../source.zip ./*
- name: Download last dissertation
uses: dawidd6/action-download-artifact@v2
continue-on-error: true
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build-dissertation.yml
- name: Check if downloaded
id: check_files
uses: andstor/file-existence-action@v1
with:
files: "Dissertation/Inesh Bose - Portion Mate.pdf"
- name: Compile LaTeX document
uses: xu-cheng/latex-action@v2
if: ${{ steps.check_files.outputs.files_exists == 'false' }}
with:
root_file: l4proj.tex
latexmk_shell_escape: true
working_directory: dissertation
extra_system_packages: "inkscape"
- name: Rename compiled PDF
if: ${{ steps.check_files.outputs.files_exists == 'false' }}
run: |
mv dissertation/l4proj.pdf "Dissertation/Inesh Bose - Portion Mate.pdf"
- name: Rename PDF
run: |
mv "Dissertation/Inesh Bose - Portion Mate.pdf" dissertation.pdf
- name: Create Release
uses: softprops/action-gh-release@v1
with:
body: ${{ steps.merged-prs.outputs.result }}
tag_name: ${{ steps.sha-substr.outputs.result }}
draft: true
files: |
timelog.md
source.zip
dissertation.pdf
16 changes: 0 additions & 16 deletions .github/workflows/group-pr.yml

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/issue-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Close issue
uses: actions/github-script@v5
uses: actions/github-script@v6
with:
script: |
github.rest.issues.update({
Expand All @@ -22,7 +22,7 @@ jobs:
state: 'closed',
})
- name: Reopen issue
uses: actions/github-script@v5
uses: actions/github-script@v6
with:
script: |
github.rest.issues.update({
Expand All @@ -48,14 +48,14 @@ jobs:
steps:
- name: Get issue number
id: get-issue-number
uses: actions/github-script@v5
uses: actions/github-script@v6
with:
script: return parseInt(context.payload.pull_request.head.ref.split('-')[0].split('/')[1])
result-encoding: string
- name: Echo issue number
run: echo "${{ steps.get-issue-number.outputs.result }}"
- name: Assign issue
uses: actions/github-script@v5
uses: actions/github-script@v6
if: ${{ steps.get-issue-number.outputs.result }}
env:
ISSUE_NUMBER: ${{ steps.get-issue-number.outputs.result }}
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/manage-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Manage Pull Requests

on:
pull_request:
types: [opened, labeled, unlabeled]

jobs:
group:
name: Group PRs for dependencies
runs-on: ubuntu-latest
if: ${{ github.event.label.name == 'dependencies' }}
steps:
- uses: actions/checkout@v3
- uses: bobvanderlinden/combine-pull-requests@v3
with:
label: dependencies
repo-token: ${{ secrets.GITHUB_TOKEN }}
close:
name: Close PRs to master
runs-on: ubuntu-latest
if: ${{ (github.head_ref != 'develop') && (github.base_ref == 'master') }}
steps:
- name: Close Pull
uses: peter-evans/close-pull@v1
with:
pull-request-number: ${{ github.event.number }}
comment: Direct merge to master restricted.
delete-branch: false
18 changes: 0 additions & 18 deletions .github/workflows/merge-master.yml

This file was deleted.

0 comments on commit e51951a

Please sign in to comment.