diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d38fb85..77271f6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -69,11 +69,23 @@ jobs: release: needs: [run_tests, i18n_translations] runs-on: ubuntu-latest + env: + CF_API_KEY: ${{ secrets.CF_API_KEY }} + WOWI_API_TOKEN: ${{ secrets.WOWI_API_TOKEN }} + WAGO_API_TOKEN: ${{ secrets.WAGO_API_TOKEN }} + GITHUB_OAUTH: ${{ secrets.GH_PAT }} permissions: contents: write steps: - name: Checkout code uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: subversion + version: test_package_apt_cache - name: Set up Node.js uses: actions/setup-node@v4 @@ -86,4 +98,16 @@ jobs: - name: Run semantic-release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: npm run semantic-release + run: node .scipts/release.js + + - name: Test + if: env.RELEASE_CREATED == 'true' + run: echo "Test" + + - name: Test 2 + if: env.RELEASE_CREATED == 'false' + run: echo "Test 2" + + # - name: Package and release + # if: env.RELEASE_CREATED == 'true' + # uses: BigWigsMods/packager@v2 diff --git a/.scripts/release.js b/.scripts/release.js new file mode 100644 index 0000000..0614fc4 --- /dev/null +++ b/.scripts/release.js @@ -0,0 +1,34 @@ +const semanticRelease = require("semantic-release"); +const fs = require("fs"); + +(async () => { + try { + const result = await semanticRelease.default({ + branches: ["main"], + plugins: [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/github", + ], + preset: "angular", + }); + + if (result) { + console.log("Release created:", result); + console.log(`Version: ${result.nextRelease.version}`); + + // Set the RELEASE_CREATED environment variable + fs.appendFileSync(process.env.GITHUB_ENV, `RELEASE_CREATED=true\n`); + process.exit(0); // Success with release + } else { + console.log("No release created."); + + // Set the RELEASE_CREATED environment variable + fs.appendFileSync(process.env.GITHUB_ENV, `RELEASE_CREATED=false\n`); + process.exit(0); // Success, but no release + } + } catch (err) { + console.error("Release failed:", err); + process.exit(1); // Failure + } +})();