Fixing issue with generating language file if custom ID is given #48
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: Build and Release | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: write | |
jobs: | |
build-and-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install dependencies and build | |
run: | | |
npm ci | |
npm run build | |
- name: Get last modified file | |
id: getfile | |
run: | | |
last_modified_file=$(ls -Art dist | tail -n 1) | |
echo "Last modified file: $last_modified_file" | |
echo "filename=$last_modified_file" >> $GITHUB_OUTPUT | |
version=$(echo $last_modified_file | sed -n 's/.*-\([0-9.]*\).c3addon/\1/p') | |
echo "Last modified file version: $version" | |
echo "version=$version" >> $GITHUB_OUTPUT | |
- name: Create Release | |
id: create_release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "dist/${{ steps.getfile.outputs.filename }}" | |
omitBody: true | |
tag: ${{ steps.getfile.outputs.filename }} | |
name: v${{ steps.getfile.outputs.version }} | |
allowUpdates: true | |
makeLatest: true | |
- name: Check if variables are set | |
id: check | |
run: | | |
publish=true | |
if [[ -z "${{ secrets.C3_AUTH_USER }}" ]]; then | |
echo "C3 AUTH_USER is not set. skip publishing." | |
publish=false | |
fi | |
if [[ -z "${{ secrets.C3_AUTH_PASSWORD }}" ]]; then | |
echo "C3 AUTH_PASSWORD is not set. skip publishing." | |
publish=false | |
fi | |
echo "publish=$publish" >> $GITHUB_OUTPUT | |
- name: Install publish dependencies | |
if: steps.check.outputs.publish == 'true' | |
run: | | |
npm install -g c3addon | |
- name: Get Addon Url | |
if: steps.check.outputs.publish == 'true' | |
id: url | |
run: | | |
url=$(grep -oP 'addonUrl:\s?"\K[^"]*' config.caw.js | cut -d '"' -f 1) | |
echo "Addon Url: $url" | |
if [[ -z "$url" ]]; then | |
echo "Addon Url is not set. skip publishing." | |
exit 1 | |
fi | |
echo "url=$url" >> $GITHUB_OUTPUT | |
- name: Publish to Construct 3 | |
if: steps.check.outputs.publish == 'true' | |
run: | | |
c3addon publish \ | |
--addonUrl '${{steps.url.outputs.url}}' \ | |
--authUser ${{ secrets.C3_AUTH_USER }} \ | |
--authPassword ${{ secrets.C3_AUTH_PASSWORD }} \ | |
--uploadFile dist/${{ steps.getfile.outputs.filename }} \ | |
--version ${{ steps.getfile.outputs.version }} \ | |
--releaseNotes 'Released via GitHub Actions' |