-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
70 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,82 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
branches: | ||
only: | ||
- "master" | ||
docker: | ||
- image: nexela/factorio-lua-env | ||
environment: | ||
TEST_REPORTS: /tmp/test-reports | ||
|
||
working_directory: ~/stdlib | ||
|
||
steps: | ||
- checkout | ||
- run: ln -s /root/project /usr/local/share/lua/5.2/__stdlib__ | ||
- run: ln -s ~/stdlib /usr/local/share/lua/5.2/__stdlib__ | ||
- run: wget -q --no-check-certificate -O .luacheckrc https://raw.githubusercontent.com/Nexela/Factorio-luacheckrc/0.17/.luacheckrc | ||
- run: luacheck . | ||
- run: busted . | ||
- run: make quick | ||
- store_artifacts: | ||
path: /root/project/.build/artifacts | ||
- run: rm .luacheckrc | ||
- run: git checkout gh-pages | ||
- run: ./generate.sh | ||
- run: git add . | ||
- run: git config user.email "[email protected]" | ||
- run: git config user.name "circleci" | ||
- run: git commit -am "Automatic Github Page generation [ci skip]" | ||
- run: git push | ||
path: ~/stdlib/.build/artifacts | ||
destination: files | ||
|
||
deploy-release: | ||
docker: | ||
- image: nexela/factorio-lua-env | ||
working_directory: ~/stdlib | ||
steps: | ||
- checkout | ||
|
||
# - run: git checkout gh-pages | ||
|
||
# - run: | | ||
# git clone https://github.com/Afforess/Factorio-Stdlib.git /tmp/stdlib | ||
# cd /tmp/stdlib | ||
# git checkout release | ||
# make quick | ||
# cp -R .build/doc/* ~/stdlib/ | ||
|
||
# - store_artifacts: | ||
# path: /tmp/stdlib/.build/artifacts | ||
# destination: files | ||
|
||
# - run: git config user.email "[email protected]" | ||
# - run: git config user.name "circleci" | ||
# - run: git add . | ||
# - run: git commit -am "Automatic Github Page generation" | ||
# - run: git push | ||
- run: git checkout release | ||
- run: | | ||
NAME=$(jq -r '.name' info.json) | ||
VERSION=$(jq -r '.version' info.json) | ||
mkdir /tmp/upload | ||
cd /tmp/upload | ||
# Get a CSRF token by loading the login form | ||
CSRF=$(curl -b cookiejar.txt -c cookiejar.txt -s https://mods.factorio.com/login | grep csrf_token | sed -r -e 's/.*value="(.*)".*/\1/') | ||
# Authenticate with the credential secrets and the CSRF token, getting a session cookie for the authorized user | ||
curl -b cookiejar.txt -c cookiejar.txt -s -F "csrf_token=${CSRF}" -F "username=${FACTORIO_USER}" -F "password=${FACTORIO_PASSWORD}" -o /dev/null https://mods.factorio.com/login | ||
# Query the mod info, verify the version number we're trying to push doesn't already exist | ||
curl -b cookiejar.txt -c cookiejar.txt -s "https://mods.factorio.com/api/mods/${NAME}/full" | jq -e ".releases[] | select(.version == \"${VERSION}\")" | ||
# store the return code before running anything else | ||
STATUS_CODE=$? | ||
if [[ $STATUS_CODE -ne 4 ]]; then | ||
echo "Release already exists, skipping" | ||
exit 78 | ||
fi | ||
echo "Release doesn't exist for ${TAG}, uploading" | ||
workflows: | ||
version: 2 | ||
build-deploy: | ||
jobs: | ||
- build: | ||
filters: | ||
branches: | ||
ignore: | ||
- gh-pages | ||
- /feature-.*/ | ||
- deploy-release: | ||
# requires: | ||
# - build | ||
filters: | ||
branches: | ||
only: release |