feat: update to 1.21.4 #101
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release Packages | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- smithed_libraries/packs/** | |
- pyproject.toml | |
workflow_dispatch: | |
env: | |
MC_VERSION: '1.21.4' | |
COMMIT_MSG: ${{ github.event.head_commit.message }} | |
jobs: | |
build-linux: | |
runs-on: ubuntu-latest | |
steps: | |
#---------------------------------------------- | |
# Setup Build Environment | |
#---------------------------------------------- | |
- name: Checkout 'main' | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Checkout 'releases' | |
uses: actions/checkout@v3 | |
with: | |
path: 'releases' | |
ref: 'releases' | |
fetch-depth: 0 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
#---------------------------------------------- | |
# ----- install & configure poetry ----- | |
#---------------------------------------------- | |
- name: Cache poetry | |
id: cache-poetry | |
uses: actions/cache@v3 | |
with: | |
path: ~/.local | |
key: poetry-${{ runner.os }} | |
- name: Install Poetry | |
if: steps.cache-poetry.outputs.cache-hit != 'true' | |
uses: snok/install-poetry@v1 | |
with: | |
version: '1.2.2' # pinned to avoid CI bugs | |
virtualenvs-in-project: true | |
- name: Setup cache | |
id: cached-poetry-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} | |
- name: Install dependencies | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install --with dev | |
#---------------------------------------------- | |
# Build packs and copy to branch | |
#---------------------------------------------- | |
- id: beet-build | |
name: Build via Beet | |
run: | | |
mkdir -p dist | |
cp releases/$MC_VERSION/manifest.json dist/manifest.json | |
poetry run python .github/workflows/build-changes.py | |
echo $(ls dist) | |
#---------------------------------------------- | |
# Commit built packs to branch | |
#---------------------------------------------- | |
# We use `&&` to ensure git steps are atomic | |
# TODO: Fix `git commit` message line | |
#---------------------------------------------- | |
- id: push-to-branch | |
name: Copy and push release files to branch | |
if: steps.beet-build.outputs.build_changes == 'true' | |
run: | | |
set -e | |
mkdir -p releases/$MC_VERSION | |
cp -rf "dist/"* releases/$MC_VERSION | |
cd releases | |
SHORT_HASH=$(git rev-parse --short HEAD) | |
VERSION="${{ steps.pypi-release.outputs.version }}" | |
git add . | |
git config --global user.name "github-actions" | |
git config --global user.email "action@github.com" | |
git commit -m "🚀 $SHORT_HASH (v$VERSION): $COMMIT_MSG" | |
git push --force origin releases | |
echo "commit_hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
#---------------------------------------------- | |
# Push to PYPI | |
#---------------------------------------------- | |
- id: pypi-release | |
name: Release for PYPI | |
if: github.repository == 'Smithed-MC/Libraries' | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | |
run: | | |
git config --global user.name "github-actions" | |
git config --global user.email "action@github.com" | |
poetry run semantic-release publish -v DEBUG -D commit_author="github-actions <action@github.com>" | |
echo "version=$(poetry run semantic-release print-version)" >> $GITHUB_OUTPUT | |
#---------------------------------------------- | |
# Push packs to Smithed via API | |
#---------------------------------------------- | |
# We load in a ton of data into env vars | |
#---------------------------------------------- | |
- name: Push built packs to Smithed | |
if: steps.beet-build.outputs.build_changes == 'true' | |
run: poetry run python .github/workflows/push-to-smithed.py | |
env: | |
COMMIT_HASH: ${{ steps.push-to-branch.outputs.commit_hash}} | |
BUILT_PACKS: ${{ steps.beet-build.outputs.built_packs }} | |
SMITHED_UID: ${{ secrets.SMITHED_UID }} | |
SMITHED_TOKEN: ${{ secrets.SMITHED_TOKEN }} |