ci(release),releaser: prepare for release

This commit is contained in:
Mark Joshwel 2023-09-06 22:28:14 +00:00
parent 7a85737fd4
commit 7f24f987e0
3 changed files with 44 additions and 10 deletions

View file

@ -3,12 +3,11 @@ name: automated tagged release with slsa 3 compliance
on: on:
push: push:
tags: tags:
- '*' - 'v*'
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
permissions: permissions:
contents: write contents: write
outputs: outputs:
@ -17,15 +16,23 @@ jobs:
steps: steps:
- name: checkout - name: checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
with:
ref: main
- name: get branch name
id: get-branch-name
uses: tj-actions/branch-names@v7
- name: install devbox - name: install devbox
uses: jetpack-io/devbox-install-action@v0.3.0 uses: jetpack-io/devbox-install-action@v0.6.1
- name: install dependencies - name: install dependencies
run: devbox run poetry install run: devbox run poetry install
- name: run releaser.py - name: run releaser.py
run: devbox run python releaser.py run: devbox run python releaser.py
env:
SURPLUS_BUILD_BRANCH: ${{ steps.get-branch-name.outputs.base_ref_branch }}
- name: build project - name: build project
id: build id: build
@ -41,6 +48,11 @@ jobs:
HASHES=$(sha256sum * | base64 -w0) HASHES=$(sha256sum * | base64 -w0)
echo "hashes=$HASHES" >> "$GITHUB_OUTPUT" echo "hashes=$HASHES" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v3
with:
name: wheels
path: dist/
- name: release - name: release
uses: softprops/action-gh-release@v0.1.15 uses: softprops/action-gh-release@v0.1.15
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')

View file

@ -14,15 +14,23 @@ jobs:
steps: steps:
- name: checkout - name: checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
with:
ref: main
- name: get branch name
id: get-branch-name
uses: tj-actions/branch-names@v7
- name: install devbox - name: install devbox
uses: jetpack-io/devbox-install-action@v0.3.0 uses: jetpack-io/devbox-install-action@v0.6.1
- name: install dependencies - name: install dependencies
run: devbox run poetry install run: devbox run poetry install
- name: run releaser.py - name: run releaser.py
run: devbox run python releaser.py run: devbox run python releaser.py
env:
SURPLUS_BUILD_BRANCH: ${{ steps.get-branch-name.outputs.base_ref_branch }}
- name: build project - name: build project
id: build id: build
@ -45,6 +53,11 @@ jobs:
files: | files: |
dist/*.whl dist/*.whl
- uses: actions/upload-artifact@v3
with:
name: wheels
path: dist/
provenance: provenance:
needs: [build] needs: [build]
permissions: permissions:

View file

@ -30,25 +30,34 @@ For more information, please refer to <http://unlicense.org/>
""" """
from datetime import datetime, timedelta, timezone from datetime import datetime, timedelta, timezone
from os import getenv
from pathlib import Path from pathlib import Path
from subprocess import run from subprocess import run
# NOTE: change this if surplus has moved # NOTE: change this if surplus has moved
path_surplus = Path(__file__).parent.joinpath("./surplus/surplus.py") path_surplus = Path(__file__).parent.joinpath("./surplus/surplus.py")
build_time = datetime.now(timezone(timedelta(hours=8))) # using SGT build_time = datetime.now(timezone(timedelta(hours=8))) # using SGT
insert_build_branch: str = run(
"git rev-parse --abbrev-ref HEAD", _insert_build_branch = getenv(
"SURPLUS_BUILD_BRANCH",
run(
"git branch --show-current",
capture_output=True, capture_output=True,
text=True, text=True,
shell=True, shell=True,
).stdout.strip("\n") ).stdout.strip("\n"),
)
insert_build_branch = _insert_build_branch if _insert_build_branch != "" else "unknown"
insert_build_commit: str = run( insert_build_commit: str = run(
"git rev-parse HEAD", "git rev-parse HEAD",
capture_output=True, capture_output=True,
text=True, text=True,
shell=True, shell=True,
).stdout.strip("\n") ).stdout.strip("\n")
insert_build_datetime: str = repr(build_time).replace("datetime.", "") insert_build_datetime: str = repr(build_time).replace("datetime.", "")
# NOTE: change this if the respective lines in surplus.py have changed # NOTE: change this if the respective lines in surplus.py have changed