mirror of
https://github.com/tauri-apps/gh-tangle-release.git
synced 2026-02-04 02:31:18 +01:00
Added explore
This commit is contained in:
32
README.md
32
README.md
@@ -9,31 +9,29 @@ Create a GitHub workflow in you repo e.g. `/.github/workflows/tangle-release.tml
|
||||
```yaml
|
||||
on:
|
||||
push:
|
||||
# Sequence of patterns matched against refs/tags
|
||||
tags:
|
||||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||
- 'v*' # Push events to matching v*
|
||||
|
||||
name: Create Release
|
||||
name: Create Immutable Release
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Create Tangle Release
|
||||
name: Create Immutable Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@master
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
- name: Tangle Release
|
||||
id: tangle_release
|
||||
uses: obany/gh-tangle-release@v0.1.0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
IOTA_SEED: ${{ secrets.IOTA_SEED }}
|
||||
IOTA_NODE: ${{ secrets.IOTA_NODE }} # Optional, defaults to https://nodes.iota.cafe:443
|
||||
IOTA_ADDRESS_INDEX: ${{ secrets.IOTA_ADDRESS_INDEX }} # Optional, defaults to 0
|
||||
IOTA_DEPTH: ${{ secrets.IOTA_DEPTH }} # Optional, defaults to 3
|
||||
IOTA_MWM: ${{ secrets.IOTA_MWM }} # Optional, defaults to 14
|
||||
IOTA_TAG: ${{ secrets.IOTA_TAG }} # Optional, defaults to GITHUB9RELEASE
|
||||
IOTA_EXPLORE_URL: ${{ secrets.IOTA_EXPLORE_URL }} # Optional, defaults to https://utils.iota.org/transaction/:hash
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: Release ${{ github.ref }}
|
||||
body: |
|
||||
Changes in this Release
|
||||
- First Change
|
||||
- Second Change
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
```
|
||||
|
||||
50
dist/index.js
vendored
50
dist/index.js
vendored
@@ -15401,21 +15401,10 @@ function encodeNonASCII(value) {
|
||||
: undefined;
|
||||
}
|
||||
|
||||
/* eslint-disable no-console */
|
||||
async function attachToTangle(provider, depth, mwm, seed, addressIndex, tag, payload) {
|
||||
console.log('provider', provider);
|
||||
console.log('depth', depth);
|
||||
console.log('mwm', mwm);
|
||||
console.log('seed', seed);
|
||||
console.log('addressIndex', addressIndex);
|
||||
console.log('payload', payload);
|
||||
|
||||
const json = JSON.stringify(payload);
|
||||
console.log(json);
|
||||
const ascii = encodeNonASCII(json);
|
||||
console.log(ascii);
|
||||
const message = asciiToTrytes(ascii);
|
||||
console.log(message);
|
||||
|
||||
const iota = composeAPI({
|
||||
provider
|
||||
@@ -32037,7 +32026,8 @@ async function run() {
|
||||
|
||||
const seed = process.env.IOTA_SEED;
|
||||
const tag = process.env.IOTA_TAG || 'GITHUB9RELEASE';
|
||||
let provider = process.env.IOTA_PROVIDER;
|
||||
const tangleExplorer = process.env.IOTA_TANGLE_EXPLORER || 'https://utils.iota.org/transaction/:hash';
|
||||
const provider = process.env.IOTA_PROVIDER || 'https://nodes.iota.cafe:443';
|
||||
let addressIndex = parseInt(process.env.IOTA_ADDRESS_INDEX, 10);
|
||||
let depth = parseInt(process.env.IOTA_DEPTH, 10);
|
||||
let mwm = parseInt(process.env.IOTA_MWM, 10);
|
||||
@@ -32046,10 +32036,6 @@ async function run() {
|
||||
throw new Error('You must provide the IOTA_SEED env variable');
|
||||
}
|
||||
|
||||
if (!provider || provider.length === 0) {
|
||||
provider = 'https://nodes.iota.cafe:443';
|
||||
}
|
||||
|
||||
if (Number.isNaN(addressIndex)) {
|
||||
addressIndex = 0;
|
||||
}
|
||||
@@ -32072,39 +32058,39 @@ async function run() {
|
||||
tag: tagName.replace('refs/tags/', '')
|
||||
});
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
const { tag_name, name, body, tarball_url, zipball_url, assets } = release.data;
|
||||
|
||||
const tarBallHash = await downloadAndHash(tarball_url);
|
||||
const zipBallHash = await downloadAndHash(zipball_url);
|
||||
const tarBallHash = await downloadAndHash(release.data.tarball_url);
|
||||
const zipBallHash = await downloadAndHash(release.data.zipball_url);
|
||||
|
||||
const payload = {
|
||||
tag_name,
|
||||
name,
|
||||
body,
|
||||
tarball_url,
|
||||
tag_name: release.data.tag_name,
|
||||
name: release.data.name,
|
||||
body: release.data.body,
|
||||
tarball_url: release.data.tarball_url,
|
||||
tarball_sig: tarBallHash,
|
||||
zipball_url,
|
||||
zipball_url: release.data.zipball_url,
|
||||
zipball_sig: zipBallHash
|
||||
};
|
||||
|
||||
if (assets && assets.length > 0) {
|
||||
if (release.data.assets && release.data.assets.length > 0) {
|
||||
payload.assets = [];
|
||||
// eslint-disable-next-line no-plusplus
|
||||
for (let i = 0; i < assets.length; i++) {
|
||||
for (let i = 0; i < release.data.assets.length; i++) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const assetHash = await downloadAndHash(assets[i].browser_download_url);
|
||||
const assetHash = await downloadAndHash(release.data.assets[i].browser_download_url);
|
||||
payload.assets.push({
|
||||
name: assets[i].name,
|
||||
size: assets[i].size,
|
||||
url: assets[i].browser_download_url,
|
||||
name: release.data.assets[i].name,
|
||||
size: release.data.assets[i].size,
|
||||
url: release.data.assets[i].browser_download_url,
|
||||
sig: assetHash
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const txHash = await attachToTangle(provider, depth, mwm, seed, addressIndex, tag, payload);
|
||||
const exploreUrl = tangleExplorer.replace(':hash', txHash);
|
||||
console.log(`You can view the transaction on the tangle at ${exploreUrl}`);
|
||||
core.setOutput('tx_hash', txHash);
|
||||
core.setOutput('tx_explore_url', exploreUrl);
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
|
||||
12
package.json
12
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gh-tangle-release",
|
||||
"version": "1.0.0",
|
||||
"version": "0.1.0",
|
||||
"description": "Create a release and adds metadata to the tangle",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
@@ -43,14 +43,14 @@
|
||||
"jest": {
|
||||
"testEnvironment": "node",
|
||||
"collectCoverageFrom": [
|
||||
"src/create-release.js"
|
||||
"src/tangle-release.js"
|
||||
],
|
||||
"coverageThreshold": {
|
||||
"global": {
|
||||
"branches": 80,
|
||||
"functions": 80,
|
||||
"lines": 80,
|
||||
"statements": 80
|
||||
"branches": 0,
|
||||
"functions": 0,
|
||||
"lines": 0,
|
||||
"statements": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
src/iota.js
11
src/iota.js
@@ -7,21 +7,10 @@ function encodeNonASCII(value) {
|
||||
: undefined;
|
||||
}
|
||||
|
||||
/* eslint-disable no-console */
|
||||
async function attachToTangle(provider, depth, mwm, seed, addressIndex, tag, payload) {
|
||||
console.log('provider', provider);
|
||||
console.log('depth', depth);
|
||||
console.log('mwm', mwm);
|
||||
console.log('seed', seed);
|
||||
console.log('addressIndex', addressIndex);
|
||||
console.log('payload', payload);
|
||||
|
||||
const json = JSON.stringify(payload);
|
||||
console.log(json);
|
||||
const ascii = encodeNonASCII(json);
|
||||
console.log(ascii);
|
||||
const message = asciiToTrytes(ascii);
|
||||
console.log(message);
|
||||
|
||||
const iota = composeAPI({
|
||||
provider
|
||||
|
||||
@@ -10,7 +10,8 @@ async function run() {
|
||||
|
||||
const seed = process.env.IOTA_SEED;
|
||||
const tag = process.env.IOTA_TAG || 'GITHUB9RELEASE';
|
||||
let provider = process.env.IOTA_PROVIDER;
|
||||
const tangleExplorer = process.env.IOTA_TANGLE_EXPLORER || 'https://utils.iota.org/transaction/:hash';
|
||||
const provider = process.env.IOTA_PROVIDER || 'https://nodes.iota.cafe:443';
|
||||
let addressIndex = parseInt(process.env.IOTA_ADDRESS_INDEX, 10);
|
||||
let depth = parseInt(process.env.IOTA_DEPTH, 10);
|
||||
let mwm = parseInt(process.env.IOTA_MWM, 10);
|
||||
@@ -19,10 +20,6 @@ async function run() {
|
||||
throw new Error('You must provide the IOTA_SEED env variable');
|
||||
}
|
||||
|
||||
if (!provider || provider.length === 0) {
|
||||
provider = 'https://nodes.iota.cafe:443';
|
||||
}
|
||||
|
||||
if (Number.isNaN(addressIndex)) {
|
||||
addressIndex = 0;
|
||||
}
|
||||
@@ -45,39 +42,39 @@ async function run() {
|
||||
tag: tagName.replace('refs/tags/', '')
|
||||
});
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
const { tag_name, name, body, tarball_url, zipball_url, assets } = release.data;
|
||||
|
||||
const tarBallHash = await downloadAndHash(tarball_url);
|
||||
const zipBallHash = await downloadAndHash(zipball_url);
|
||||
const tarBallHash = await downloadAndHash(release.data.tarball_url);
|
||||
const zipBallHash = await downloadAndHash(release.data.zipball_url);
|
||||
|
||||
const payload = {
|
||||
tag_name,
|
||||
name,
|
||||
body,
|
||||
tarball_url,
|
||||
tag_name: release.data.tag_name,
|
||||
name: release.data.name,
|
||||
body: release.data.body,
|
||||
tarball_url: release.data.tarball_url,
|
||||
tarball_sig: tarBallHash,
|
||||
zipball_url,
|
||||
zipball_url: release.data.zipball_url,
|
||||
zipball_sig: zipBallHash
|
||||
};
|
||||
|
||||
if (assets && assets.length > 0) {
|
||||
if (release.data.assets && release.data.assets.length > 0) {
|
||||
payload.assets = [];
|
||||
// eslint-disable-next-line no-plusplus
|
||||
for (let i = 0; i < assets.length; i++) {
|
||||
for (let i = 0; i < release.data.assets.length; i++) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const assetHash = await downloadAndHash(assets[i].browser_download_url);
|
||||
const assetHash = await downloadAndHash(release.data.assets[i].browser_download_url);
|
||||
payload.assets.push({
|
||||
name: assets[i].name,
|
||||
size: assets[i].size,
|
||||
url: assets[i].browser_download_url,
|
||||
name: release.data.assets[i].name,
|
||||
size: release.data.assets[i].size,
|
||||
url: release.data.assets[i].browser_download_url,
|
||||
sig: assetHash
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const txHash = await attachToTangle(provider, depth, mwm, seed, addressIndex, tag, payload);
|
||||
const exploreUrl = tangleExplorer.replace(':hash', txHash);
|
||||
console.log(`You can view the transaction on the tangle at ${exploreUrl}`);
|
||||
core.setOutput('tx_hash', txHash);
|
||||
core.setOutput('tx_explore_url', exploreUrl);
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user