Try new release flow
This commit is contained in:
102
.github/workflows/build.yml
vendored
102
.github/workflows/build.yml
vendored
@@ -36,7 +36,7 @@ jobs:
|
|||||||
xgo_version: latest
|
xgo_version: latest
|
||||||
go_version: 1.21
|
go_version: 1.21
|
||||||
pkg: cmd/zurg
|
pkg: cmd/zurg
|
||||||
targets: linux/amd64
|
targets: linux/amd64,windows/amd64,darwin/amd64
|
||||||
dest: artifacts
|
dest: artifacts
|
||||||
prefix: zurg
|
prefix: zurg
|
||||||
v: false
|
v: false
|
||||||
@@ -148,3 +148,103 @@ jobs:
|
|||||||
git add .
|
git add .
|
||||||
git commit -m "Release ${{ steps.version.outputs.version }}"
|
git commit -m "Release ${{ steps.version.outputs.version }}"
|
||||||
git push
|
git push
|
||||||
|
|
||||||
|
- name: Create Release in Target Repository
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const githubToken = '${{ secrets.TOKEN }}';
|
||||||
|
const octokit = github.getOctokit(githubToken);
|
||||||
|
|
||||||
|
const ownerName = 'debridmediamanager';
|
||||||
|
const repoName = 'zurg-early-releases';
|
||||||
|
const tagName = '${{ steps.version.outputs.version }}';
|
||||||
|
const releaseName = `Release ${tagName}`;
|
||||||
|
|
||||||
|
// Fetch the latest release to calculate time since last release
|
||||||
|
const latestRelease = await octokit.rest.repos.getLatestRelease({
|
||||||
|
owner: ownerName,
|
||||||
|
repo: repoName,
|
||||||
|
});
|
||||||
|
|
||||||
|
const lastReleaseTime = new Date(latestRelease.data.published_at);
|
||||||
|
const currentTime = new Date();
|
||||||
|
const hoursSinceLastRelease = ((currentTime - lastReleaseTime) / 3600000).toFixed(2);
|
||||||
|
|
||||||
|
// Sponsorship details
|
||||||
|
const sponsorshipDetails = `
|
||||||
|
Support our project:
|
||||||
|
- Patreon: https://www.patreon.com/debridmediamanager
|
||||||
|
- GitHub Sponsors: https://github.com/sponsors/debridmediamanager
|
||||||
|
- PayPal: https://paypal.me/yowmamasita
|
||||||
|
`;
|
||||||
|
|
||||||
|
// Query GitHub sponsors
|
||||||
|
async function getGithubSponsors() {
|
||||||
|
const query = `
|
||||||
|
query {
|
||||||
|
viewer {
|
||||||
|
sponsorshipsAsMaintainer(first: 100) {
|
||||||
|
nodes {
|
||||||
|
sponsorEntity {
|
||||||
|
... on User {
|
||||||
|
login
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await octokit.graphql(query);
|
||||||
|
return response.viewer.sponsorshipsAsMaintainer.nodes
|
||||||
|
.filter(node => node.sponsorEntity)
|
||||||
|
.map(node => node.sponsorEntity.login);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching GitHub sponsors: ", error);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const githubSponsors = await getGithubSponsors();
|
||||||
|
|
||||||
|
// Constructing the release body
|
||||||
|
const releaseBody = `
|
||||||
|
Release: ${tagName}
|
||||||
|
Hours since last release: ${hoursSinceLastRelease} hours
|
||||||
|
|
||||||
|
${sponsorshipDetails}
|
||||||
|
|
||||||
|
Shoutouts to our amazing sponsors! ${githubSponsors.join(', ')}
|
||||||
|
`;
|
||||||
|
|
||||||
|
// Create a release
|
||||||
|
const response = await octokit.rest.repos.createRelease({
|
||||||
|
owner: ownerName,
|
||||||
|
repo: repoName,
|
||||||
|
tag_name: tagName,
|
||||||
|
name: releaseName,
|
||||||
|
body: releaseBody,
|
||||||
|
});
|
||||||
|
|
||||||
|
const uploadUrl = response.data.upload_url;
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const artifactsPath = 'compressed_artifacts';
|
||||||
|
fs.readdirSync(artifactsPath).forEach(async (file) => {
|
||||||
|
const filePath = path.join(artifactsPath, file);
|
||||||
|
const fileStream = fs.createReadStream(filePath);
|
||||||
|
await octokit.rest.repos.uploadReleaseAsset({
|
||||||
|
url: uploadUrl,
|
||||||
|
headers: {
|
||||||
|
'content-type': 'application/octet-stream',
|
||||||
|
'content-length': fs.statSync(filePath).size
|
||||||
|
},
|
||||||
|
name: file,
|
||||||
|
data: fileStream
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user