From 11a2226bfd4cf17c525c55105edbb6eae073d988 Mon Sep 17 00:00:00 2001 From: Lucas Brandstaetter Date: Tue, 1 Oct 2019 21:31:32 +0200 Subject: [PATCH 01/11] converted main.workflow to Actions V2 yml files --- .github/main.workflow | 38 -------------------------------------- .github/workflows/push.yml | 26 ++++++++++++++++++++++++++ CHANGELOG.md | 9 +++++++++ 3 files changed, 35 insertions(+), 38 deletions(-) delete mode 100644 .github/main.workflow create mode 100644 .github/workflows/push.yml create mode 100644 CHANGELOG.md diff --git a/.github/main.workflow b/.github/main.workflow deleted file mode 100644 index 748cf5e..0000000 --- a/.github/main.workflow +++ /dev/null @@ -1,38 +0,0 @@ -workflow "Check & Release" { - on = "push" - resolves = ["Create GitHub release"] -} - -action "lint" { - uses = "docker://cdssnc/docker-lint-github-action" - args = "--ignore DL3007 --ignore DL3018" -} - -action "shfmt" { - uses = "roang-zero1/actions/shfmt@master" - secrets = ["GITHUB_TOKEN"] - env = { - SHFMT_ARGS="-i 2 -ci", - } -} - -action "filter tag" { - uses = "actions/bin/filter@3c0b4f0e63ea54ea5df2914b4fabf383368cd0da" - args = "tag" - needs = [ - "lint", - "shfmt", - ] -} - -action "Create GitHub release" { - uses = "Roang-zero1/github-create-release-action@master" - env = { - VERSION_REGEX = "^v[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+", - UPDATE_EXISTING = "y", - } - secrets = [ - "GITHUB_TOKEN" - ] - needs = ["filter tag"] -} diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 0000000..8621cfc --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,26 @@ +on: push +name: Check & Release +jobs: + shfmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: shfmt + uses: bltavares/actions/shfmt@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SHFMT_ARGS: -i 2 -ci + - name: lint + uses: docker://cdssnc/docker-lint-github-action + with: + args: --ignore DL3007 --ignore DL3018 + - name: filter tag + uses: actions/bin/filter@3c0b4f0e63ea54ea5df2914b4fabf383368cd0da + with: + args: tag + - name: Create GitHub release + uses: Roang-zero1/github-create-release-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + UPDATE_EXISTING: "y" + VERSION_REGEX: ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e15450b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# CHANGELOG + +## v1.0.1 + +* Migrate to Actions V2 yml files + +## v1.0.0 + +Initial Release From 1bf60dc5930d1dfb47ab2cf906453af985f36db4 Mon Sep 17 00:00:00 2001 From: Lucas Brandstaetter Date: Sun, 13 Oct 2019 01:06:29 +0200 Subject: [PATCH 02/11] Update main workflow --- .../workflows/{push.yml => check-release.yml} | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) rename .github/workflows/{push.yml => check-release.yml} (56%) diff --git a/.github/workflows/push.yml b/.github/workflows/check-release.yml similarity index 56% rename from .github/workflows/push.yml rename to .github/workflows/check-release.yml index 8621cfc..2b4c03f 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/check-release.yml @@ -1,26 +1,32 @@ -on: push name: Check & Release +on: [push, pull_request] jobs: shfmt: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - - name: shfmt + - name: Format and check with shfmt uses: bltavares/actions/shfmt@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SHFMT_ARGS: -i 2 -ci - - name: lint + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Lint docker file (docker-lint) uses: docker://cdssnc/docker-lint-github-action with: args: --ignore DL3007 --ignore DL3018 - - name: filter tag - uses: actions/bin/filter@3c0b4f0e63ea54ea5df2914b4fabf383368cd0da - with: - args: tag + release: + runs-on: ubuntu-latest + needs: [shfmt, lint] + if: startsWith(github.ref, 'refs/tags/') + steps: - name: Create GitHub release uses: Roang-zero1/github-create-release-action@master + with: + version_regex: '^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+' + update_existing: 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - UPDATE_EXISTING: "y" - VERSION_REGEX: ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+ From c90dbaa7af8cdc7296fdeabe4a3473a97aa701db Mon Sep 17 00:00:00 2001 From: Lucas Brandstaetter Date: Fri, 18 Oct 2019 17:15:30 +0200 Subject: [PATCH 03/11] Update to Actions v2 format --- Dockerfile | 7 +------ action.yml | 9 +++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 action.yml diff --git a/Dockerfile b/Dockerfile index 02cea98..7f04da5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,4 @@ -FROM roangzero1/factorio-mod:luarocks5.3-alpine as base - -LABEL "com.github.actions.name"="GitHub Action for Factorio Mod Release" -LABEL "com.github.actions.description"="Uploada Factorio mod to the mod portal." -LABEL "com.github.actions.icon"="upload" -LABEL "com.github.actions.color"="orange" +FROM docker.pkg.github.com/roang-zero1/factorio-mod-actions/factorio-mod:luarocks5.3-alpine LABEL "repository"="https://github.com/Roang-zero1/factorio-create-release-action" LABEL "homepage"="https://github.com/Roang-zero1/factorio-create-release-action" diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..16582bb --- /dev/null +++ b/action.yml @@ -0,0 +1,9 @@ +name: "GitHub Action for Factorio Mod Release" +description: "Upload a Factorio mod to the mod portal." +author: "Roang_zero1 " +branding: + icon: "upload" + color: "orange" +runs: + using: "docker" + image: "Dockerfile" From f515bacc24999e35efb6654681a18fbae9180cc4 Mon Sep 17 00:00:00 2001 From: Lucas Brandstaetter Date: Fri, 18 Oct 2019 17:38:23 +0200 Subject: [PATCH 04/11] Remove changelog json check This check is only relevant if you use my CHANGELOG creator. --- entrypoint.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 64a9bb2..7829d3c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -22,11 +22,6 @@ if ! [[ ${PACKAGE_VERSION} == "${TAG}" ]]; then exit 1 fi -if ! grep -q "\"$PACKAGE_VERSION\"" changelog.json; then - echo "ERROR: Changelog is missing." 1>&2 - exit 1 -fi - if ! grep -q "$PACKAGE_VERSION" changelog.txt; then echo "ERROR: Changelog was not compiled." 1>&2 exit 1 From d8fe0c64a8d08bba890e5499f4e613ba14d066fa Mon Sep 17 00:00:00 2001 From: Lucas Brandstaetter Date: Sat, 19 Oct 2019 15:02:30 +0200 Subject: [PATCH 05/11] Update to Actions v2 inputs --- action.yml | 7 +++++++ entrypoint.sh | 12 ++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 16582bb..e0162d8 100644 --- a/action.yml +++ b/action.yml @@ -4,6 +4,13 @@ author: "Roang_zero1 " branding: icon: "upload" color: "orange" +inputs: + factorio_user: + description: "User that will be used to authenticate to the Factorio mod-portal." + required: true + factorio_password: + description: "Password that will be used to authenticate to the Factorio mod-portal." + required: true runs: using: "docker" image: "Dockerfile" diff --git a/entrypoint.sh b/entrypoint.sh index 7829d3c..5fd9bb1 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,13 @@ #!/bin/sh +# Backwards compatibility mapping +if [ -z $FACTORIO_USER ]; then :; else + INPUT_FACTORIO_USER=$FACTORIO_USER +fi +if [ -z $FACTORIO_PASSWORD ]; then :; else + INPUT_FACTORIO_PASSWORD=$FACTORIO_PASSWORD +fi + if [ "${GITHUB_REF}" == "${GITHUB_REF#refs/tags/}" ]; then echo "This is not a tagged push." 1>&2 exit 78 @@ -47,8 +55,8 @@ curl -sSL \ -b cookiejar.txt \ -c cookiejar.txt \ -F "csrf_token=${CSRF}" \ - -F "username=${FACTORIO_USER}" \ - -F "password=${FACTORIO_PASSWORD}" \ + -F "username=${INPUT_FACTORIO_USER}" \ + -F "password=${INPUT_FACTORIO_PASSWORD}" \ -o /dev/null \ https://mods.factorio.com/login From 98214110d3e63593a3d646fb26c01aff0dac11cd Mon Sep 17 00:00:00 2001 From: Lucas Brandstaetter Date: Sat, 19 Oct 2019 15:03:15 +0200 Subject: [PATCH 06/11] Update README Document the inputs, update workflow reference. --- README.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 680aa06..6331c60 100644 --- a/README.md +++ b/README.md @@ -4,17 +4,22 @@ This action will upload you Mod to the [Factorio Mod Portal](https://mods.factor ## Sample Workflow -A sample workflow that uses this action can be found at [Roang-zero1/factorio-mod-actions](https://github.com/Roang-zero1/factorio-mod-actions/blob/master/sample/main.workflow) +A sample workflow that uses this action can be found at [Roang-zero1/factorio-mod-actions](https://github.com/Roang-zero1/factorio-mod-actions/blob/master/sample/push-check-release.yml) -## Secrets +## Inputs -* `FACTORIO_USER` Username of the mod portal -* `FACTORIO_PASSWORD` Password of the mod portal +### `factorio_user` + +**Required** User that will be used to authenticate to the Factorio mod-portal. + +### `factorio_password` + +**Required** Password that will be used to authenticate to the Factorio mod-portal. ## Acknowledgements Factorio build scripts based on: -* [Nexelas Mods](https://github.com/Nexela) -* [GitHub Action to automatically publish to the Factorio mod portal](https://github.com/shanemadden/factorio-mod-portal-publish) -* Shane Madden (Nymbia) +- [Nexelas Mods](https://github.com/Nexela) +- [GitHub Action to automatically publish to the Factorio mod portal](https://github.com/shanemadden/factorio-mod-portal-publish) +- Shane Madden (Nymbia) From 704d92536b43b5ab43e9cfe0855f4ecc3a5e414d Mon Sep 17 00:00:00 2001 From: Lucas Brandstaetter Date: Sun, 20 Oct 2019 00:09:58 +0200 Subject: [PATCH 07/11] Prepare release --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e15450b..3792dc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,15 @@ # CHANGELOG +## v1.1.0 + +Update Action to v2 format + +- Create `action.yml` +- Add input parameters + ## v1.0.1 -* Migrate to Actions V2 yml files +- Migrate to Actions V2 yml files ## v1.0.0 From 280ad3611ca44b5ad03ede2c767c373a09c5daf5 Mon Sep 17 00:00:00 2001 From: Lucas Brandstaetter Date: Sun, 20 Oct 2019 00:34:05 +0200 Subject: [PATCH 08/11] Update release workflow --- .github/workflows/check-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check-release.yml b/.github/workflows/check-release.yml index 2b4c03f..4b8f704 100644 --- a/.github/workflows/check-release.yml +++ b/.github/workflows/check-release.yml @@ -23,6 +23,7 @@ jobs: needs: [shfmt, lint] if: startsWith(github.ref, 'refs/tags/') steps: + - uses: actions/checkout@master - name: Create GitHub release uses: Roang-zero1/github-create-release-action@master with: From 264d3cb7cb2977737ee8e32acc9f6bf063084ca2 Mon Sep 17 00:00:00 2001 From: Lucas B Date: Wed, 25 Dec 2019 14:48:46 +0100 Subject: [PATCH 09/11] Update Dockerfile to be based on alpine --- CHANGELOG.md | 4 ++++ Dockerfile | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3792dc6..5496331 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## v1.1.1 + +Update Dockerfile to be based on alpine + ## v1.1.0 Update Action to v2 format diff --git a/Dockerfile b/Dockerfile index 7f04da5..f9f210d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,11 @@ -FROM docker.pkg.github.com/roang-zero1/factorio-mod-actions/factorio-mod:luarocks5.3-alpine +FROM alpine:3.9.3 LABEL "repository"="https://github.com/Roang-zero1/factorio-create-release-action" LABEL "homepage"="https://github.com/Roang-zero1/factorio-create-release-action" LABEL "maintainer"="Roang_zero1 " +RUN apk add --no-cache curl jq + COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] From d67e0de6410c8d5c4025223936ac7af6d730c753 Mon Sep 17 00:00:00 2001 From: Lucas Brandstaetter Date: Sat, 15 Feb 2020 09:13:17 +0100 Subject: [PATCH 10/11] Improve output clarity Fixes #1. --- entrypoint.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 5fd9bb1..83e827c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -26,12 +26,13 @@ export PACKAGE_FULL_NAME=$PACKAGE_NAME\_$PACKAGE_VERSION export PACKAGE_FILE="$PACKAGE_FULL_NAME.zip" if ! [[ ${PACKAGE_VERSION} == "${TAG}" ]]; then - echo "Tag version (${TAG}) doesn't match info.json version (${PACKAGE_VERSION}) (or info.json is invalid)." 1>&2 + echo "ERROR: Tag version (${TAG}) doesn't match info.json version (${PACKAGE_VERSION}) (or info.json is invalid)." 1>&2 exit 1 fi if ! grep -q "$PACKAGE_VERSION" changelog.txt; then - echo "ERROR: Changelog was not compiled." 1>&2 + echo "ERROR: Current version (${PACKAGE_VERSION}) not found in 'changelog.txt'. Please add ingame changelog for current version." 1>&2 + echo "See https://forums.factorio.com/viewtopic.php?f=25&t=67140 for mor information." 1>&2 exit 1 fi @@ -83,7 +84,7 @@ UPLOAD_TOKEN=$(curl -sSL \ sed -r -e "s/.*token: '(.*)'.*/\1/") if [[ -z ${UPLOAD_TOKEN} ]]; then - echo "Couldn't get an upload token, failed" + echo "ERROR: Couldn't get an upload token, failed" 1>&2 exit 1 fi @@ -101,7 +102,7 @@ FILENAME=$(echo "${UPLOAD_RESULT}" | jq -r '.filename') THUMBNAIL=$(echo "${UPLOAD_RESULT}" | jq -r '.thumbnail // empty') if [[ ${FILENAME} == "null" ]] || [[ -z ${FILENAME} ]]; then - echo "Upload failed" + echo "ERROR: Upload failed" 1>&2 exit 1 fi @@ -121,6 +122,6 @@ HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://') if [ $HTTP_STATUS -eq 200 ]; then echo "Release upload completed" else - echo "Failed to upload release" + echo "ERROR: Failed to upload release" 1>&2 exit 1 fi From 475c19da6bc7f30f278b9ed160bc37663036133f Mon Sep 17 00:00:00 2001 From: Lucas B Date: Sat, 15 Feb 2020 09:29:11 +0100 Subject: [PATCH 11/11] Prepare release --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5496331..f0a661e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## v1.1.2 + +Improve error messages + ## v1.1.1 Update Dockerfile to be based on alpine