Skip to content

Commit

Permalink
ci: test release wrapper script
Browse files Browse the repository at this point in the history
  • Loading branch information
Mctalian committed Jan 5, 2025
1 parent 842557e commit ea55787
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
26 changes: 25 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
34 changes: 34 additions & 0 deletions .scripts/release.js
Original file line number Diff line number Diff line change
@@ -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
}
})();

0 comments on commit ea55787

Please sign in to comment.