Merge branch 'main' of https://github.com/dig1t/red #15
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
# https://github.com/nightcycle/occlusion-camera/blob/main/.github/workflows/release.yml | |
name: Release package | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- 'version.txt' | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
fetch-depth: 0 | |
submodules: recursive | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Get version | |
id: version | |
uses: actions/[email protected] | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const core = require('@actions/core') | |
const fs = require('fs'); | |
const version = fs.readFileSync('${{ github.workspace }}/version.txt', 'utf8') | |
core.setOutput('version', version); | |
console.log(version) | |
- name: Update files with new version | |
id: update-files | |
shell: bash | |
run: | | |
# read wally.toml file | |
wallyTOMLContents=$(<wally.toml) | |
# swap out name | |
targetNameLine=$(echo "$wallyTOMLContents" | grep -F "name = ") | |
goalNameLine="name = \"${{github.repository}}\"" | |
wallyTOMLContents="${wallyTOMLContents/${targetNameLine}/${goalNameLine}}" | |
# swap out version | |
targetVersionLine=$(echo "$wallyTOMLContents" | grep -F "version = ") | |
goalVersionLine="version = \"${{ steps.version.outputs.version }}\"" | |
wallyTOMLContents="${wallyTOMLContents/${targetVersionLine}/${goalVersionLine}}" | |
# update wally.toml file | |
echo "$wallyTOMLContents" > wally.toml | |
# read package.json file | |
defaultJSONContents=$(<package.json) | |
targetJSONVersionLine=$(echo "$defaultJSONContents" | grep -F "\"version\": ") | |
goalJSONVersionLine=" \"version\": \"${{ steps.version.outputs.version }}\"," | |
defaultJSONContents="${defaultJSONContents/${targetJSONVersionLine}/${goalJSONVersionLine}}" | |
# update package.json file | |
echo "$defaultJSONContents" > package.json | |
# read README.md file | |
readmeContents=$(<README.md) | |
targetReadmeVersionLine=$(echo "$readmeContents" | grep -F "${{ github.event.repository.name }} = \"") | |
goalReadmeVersionLine="${{ github.event.repository.name }} = \"${{github.repository}}@${{ steps.version.outputs.version }}\"" | |
readmeContents="${readmeContents/${targetReadmeVersionLine}/${goalReadmeVersionLine}}" | |
# update README.md file | |
echo "$readmeContents" > README.md | |
- name: Commit files with new version | |
id: commit-files | |
run: | | |
# Commit version update | |
git config user.name "$(git log -n 1 --pretty=format:%an)" | |
git config user.email "$(git log -n 1 --pretty=format:%ae)" | |
git add --all | |
git commit -m "Update to v${{ steps.version.outputs.version }}" | |
git push -u origin main --force-with-lease || true | |
COMMIT_SHA=$(git rev-parse HEAD) | |
echo "Committed changes" | |
echo "commitSHA=$COMMIT_SHA" >> $GITHUB_OUTPUT | |
# Create GitHub release | |
- name: Create ${{ steps.version.outputs.version }} Runner Release | |
uses: actions/create-release@master | |
id: createRelease | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "v${{ steps.version.outputs.version }}" | |
release_name: "v${{ steps.version.outputs.version }}" | |
commitish: ${{ steps.commit-files.outputs.commitSHA }} | |
- name: Install aftman dependencies | |
uses: ok-nick/[email protected] | |
- name: Install dependencies | |
run: npm run build:dependencies | |
- name: Publish to wally | |
shell: bash | |
env: | |
WALLY_TOKEN: ${{ secrets.WALLY_TOKEN }} | |
run: | | |
rm -rf packages testez.toml .github node_modules .vscode | |
mkdir -p ~/.wally | |
printf "[tokens]\n\"https://api.wally.run/\" = \"%s\"" "$WALLY_TOKEN" >> ~/.wally/auth.toml | |
wally publish | |
- name: Build package place file | |
run: rojo build -o ${{ github.event.repository.name }}.rbxl build.project.json | |
- name: Upload Roblox level file to release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.createRelease.outputs.upload_url }} | |
asset_path: ${{ github.event.repository.name }}.rbxl | |
asset_name: ${{ github.event.repository.name }}.rbxl | |
asset_content_type: application/octet-stream |