diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 00000000..43ed0bb2 --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,15 @@ +name: Pulumi Preview +on: + pull_request: + branches: + - main + push: + branches: + - main +jobs: + preview: + name: Preview + uses: ./.github/workflows/setup.yml + secrets: inherit + with: + pulumi-command: preview diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml deleted file mode 100644 index 93cf681f..00000000 --- a/.github/workflows/pull-request.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Pulumi -on: - pull_request: - branches: - - main -jobs: - preview: - name: Preview - runs-on: ubuntu-latest - steps: - - - uses: actions/checkout@v2 - with: - fetch-depth: 1 - submodules: true - token : ${{ secrets.ACCESS_TOKEN }} - - - uses: actions/setup-node@v1 - with: - node-version: 14.x - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-region: ${{ secrets.AWS_REGION }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - role-to-assume: tempKubernetesAdmin - - - - name: Add profile credentials to ~/.aws/credentials - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - run: | - aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile oxheadalpha - aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile oxheadalpha - - - name: Install Pulumi CLI - uses: pulumi/action-install-pulumi-cli@v1.0.1 - with: - pulumi-version: 3.4.0 - - - run: npm install - - - uses: pulumi/actions@v3 - with: - command: preview - stack-name: tqtezos/teztnets/teztnets - - env: - PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }} - diff --git a/.github/workflows/push-to-main.yml b/.github/workflows/push-to-main.yml deleted file mode 100644 index 91510df7..00000000 --- a/.github/workflows/push-to-main.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Pulumi -on: - push: - branches: - - main -jobs: - preview: - name: Preview - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 1 - submodules: true - - - uses: actions/setup-node@v1 - with: - node-version: 14.x - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-region: ${{ secrets.AWS_REGION }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - role-to-assume: tempKubernetesAdmin - - - - name: Add profile credentials to ~/.aws/credentials - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - run: | - aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile oxheadalpha - aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile oxheadalpha - - - name: Install Pulumi CLI - uses: pulumi/action-install-pulumi-cli@v1.0.1 - with: - pulumi-version: 3.4.0 - - - run: npm install - - - uses: pulumi/actions@v3 - with: - command: preview - stack-name: tqtezos/teztnets/teztnets - env: - PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3f03c7ca..989e807e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,61 +1,20 @@ -name: Publish teztnets +name: Publish Teztnets on: push: tags: - - 'v*' + - "v*" schedule: # update the deployment every Monday at 0:00 UTC - - cron: '0 0 * * *' + - cron: "0 0 * * *" jobs: up: - name: up - runs-on: ubuntu-latest - outputs: - networks: ${{ steps.pup.outputs.networks }} - teztnets: ${{ steps.pup.outputs.teztnets }} - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 1 - submodules: true - token : ${{ secrets.ACCESS_TOKEN }} - - - uses: actions/setup-node@v1 - with: - node-version: 14.x - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-region: ${{ secrets.AWS_REGION }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - role-to-assume: tempKubernetesAdmin - - - - name: Add profile credentials to ~/.aws/credentials - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - run: | - aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile oxheadalpha - aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile oxheadalpha - - - name: Install Pulumi CLI - uses: pulumi/action-install-pulumi-cli@v1.0.1 - with: - pulumi-version: 3.32.1 - - run: npm install - - - uses: pulumi/actions@v3 - id: pup - with: - command: up - stack-name: tqtezos/teztnets/teztnets - env: - PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }} + name: Up + uses: ./.github/workflows/setup.yml + secrets: inherit + with: + pulumi-command: up build: needs: up @@ -81,8 +40,6 @@ jobs: - name: generate release artifacts run: | python src/release.py - env: - FAUCET_RECAPTCHA_SITE_KEY: ${{secrets.FAUCET_RECAPTCHA_SITE_KEY }} - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml new file mode 100644 index 00000000..eaea217e --- /dev/null +++ b/.github/workflows/setup.yml @@ -0,0 +1,50 @@ +name: Pulumi Setup +on: + workflow_call: + inputs: + pulumi-command: + required: true + type: string + +jobs: + pulumi: + runs-on: ubuntu-latest + outputs: + networks: ${{ steps.pup.outputs.networks }} + teztnets: ${{ steps.pup.outputs.teztnets }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + submodules: true + + - uses: actions/setup-node@v3 + with: + node-version: 16.x + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v3 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-region: ${{ secrets.AWS_REGION }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + role-to-assume: tempKubernetesAdmin + + - name: Add profile credentials to ~/.aws/credentials + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + run: | + aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile oxheadalpha_tempKubernetesAdmin + aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile oxheadalpha_tempKubernetesAdmin + + - run: npm install + + - uses: pulumi/actions@v4 + id: pup + with: + command: ${{ inputs.pulumi-command }} + stack-name: tqtezos/teztnets/teztnets + env: + PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }} + diff --git a/Pulumi.teztnets.yaml b/Pulumi.teztnets.yaml index 037dcc68..28442c2a 100644 --- a/Pulumi.teztnets.yaml +++ b/Pulumi.teztnets.yaml @@ -1,5 +1,5 @@ config: - aws:profile: oxheadalpha + aws:profile: oxheadalpha_tempKubernetesAdmin aws:region: us-east-2 teztnets:aws-account-id: secure: AAABAKrODV/Bg/UQH/m6XVe4fijcmBQ6K0ip2ywd1EKRxaVh4vfNgWytrRg= diff --git a/src/release.py b/src/release.py index 780f864d..fbf3a864 100644 --- a/src/release.py +++ b/src/release.py @@ -7,61 +7,92 @@ shutil.copytree("src/website", "target/release", dirs_exist_ok=True) teztnets = {} -with open("./teztnets.json", 'r') as teztnets_file: +with open("./teztnets.json", "r") as teztnets_file: teztnets = json.load(teztnets_file) networks = {} -with open("./networks.json", 'r') as networks_file: +with open("./networks.json", "r") as networks_file: networks = json.load(networks_file) for network_name in networks: with open(f"target/release/{network_name}", "w") as out_file: - print(json.dumps(networks[network_name], indent = 2), file=out_file) + print(json.dumps(networks[network_name], indent=2), file=out_file) # group by category for human rendering # Order manually. Start with long-running. category_desc = { - "Long-running Teztnets": "If you are not sure, pick this one.", - "Protocol Teztnets":"Testnets deployed specifically to test new Tezos protocol proposals.", - "Periodic Teztnets": "Testnets that restart regularly and track the development of the master branch of [Octez repo](https://gitlab.com/tezos/tezos/).\n \n☠️ You probably don't want this unless you are a core protocol developer." } -nested_teztnets = {"Long-running Teztnets":{}, "Protocol Teztnets":{}, "Periodic Teztnets":{}} -for k,v in teztnets.items(): + "Long-running Teztnets": "If you are not sure, pick this one.", + "Protocol Teztnets": "Testnets deployed specifically to test new Tezos protocol proposals.", + "Periodic Teztnets": "Testnets that restart regularly and track the development of the master branch of [Octez repo](https://gitlab.com/tezos/tezos/).\n \n☠️ You probably don't want this unless you are a core protocol developer.", +} + +nested_teztnets = { + "Long-running Teztnets": {}, + "Protocol Teztnets": {}, + "Periodic Teztnets": {}, +} + +for k, v in teztnets.items(): if v["masked_from_main_page"]: continue if v["category"] not in nested_teztnets: nested_teztnets[v["category"]] = {} nested_teztnets[v["category"]][k] = v - nested_teztnets[v["category"]][k]["activated_on"] = networks[k]["genesis"]["timestamp"].split("T")[0] + nested_teztnets[v["category"]][k]["activated_on"] = networks[k]["genesis"][ + "timestamp" + ].split("T")[0] + +index = jinja2.Template(open("src/release_notes.md.jinja2").read()).render( + teztnets=nested_teztnets, category_desc=category_desc +) -index = jinja2.Template(open('src/release_notes.md.jinja2').read()).render(teztnets=nested_teztnets, category_desc=category_desc) with open("target/release-notes.markdown", "w") as out_file: print(index, file=out_file) with open("target/release/index.markdown", "a") as out_file: print(index, file=out_file) with open("target/release/teztnets.json", "w") as out_file: - print(json.dumps(teztnets, indent = 2), file=out_file) + print(json.dumps(teztnets, indent=2), file=out_file) -for k,v in teztnets.items(): +for k, v in teztnets.items(): if k == "mainnet": continue + v["release"] = None if "tezos/tezos:v" in v["docker_build"]: - v["release"] = v["docker_build"].split("tezos/tezos:")[1] + v["release"] = v["docker_build"].split("tezos/tezos:")[1] v["docker_build_hyperlinked"] = v["docker_build"] + if v["docker_build"].startswith("tezos/tezos"): # build from docker hub, providing a link - v["docker_build_hyperlinked"] = "[" + v['docker_build'] + "](https://hub.docker.com/r/tezos/tezos/tags?page=1&ordering=last_updated&name=" + v['docker_build'].replace('tezos/tezos:', '') + ")" - + v["docker_build_hyperlinked"] = ( + "[" + + v["docker_build"] + + "](https://hub.docker.com/r/tezos/tezos/tags?page=1&ordering=last_updated&name=" + + v["docker_build"].replace("tezos/tezos:", "") + + ")" + ) + v["git_repo"] = "git@gitlab.com:tezos/tezos.git" readme = "" + if os.path.exists(f"{k.split('-')[0]}/README.md"): with open(f"{k.split('-')[0]}/README.md") as readme_file: readme = readme_file.read() - teztnet_md = jinja2.Template(open('src/teztnet_page.md.jinja2').read()).render(k=k,v=v, network_params=networks[k], readme=readme) - faucet_md = jinja2.Template(open('src/teztnet_faucet.md.jinja2').read()).render(k=k,v=v, faucet_recaptcha_site_key=os.environ["FAUCET_RECAPTCHA_SITE_KEY"]) - with open(f"target/release/{v['human_name'].lower()}-about.markdown", "w") as out_file: + + teztnet_md = jinja2.Template(open("src/teztnet_page.md.jinja2").read()).render( + k=k, v=v, network_params=networks[k], readme=readme + ) + + faucet_md = jinja2.Template(open("src/teztnet_faucet.md.jinja2").read()).render( + k=k, v=v + ) + + with open( + f"target/release/{v['human_name'].lower()}-about.markdown", "w" + ) as out_file: print(teztnet_md, file=out_file) + with open(f"target/release/{k}-faucet.markdown", "w") as out_file: print(faucet_md, file=out_file) @@ -71,4 +102,4 @@ with open(f"target/release/{alias}-faucet.markdown", "w") as out_file: print(f"{alias} is now {k}, go to [{k}-faucet]({k}-faucet)", file=out_file) with open(f"target/release/{alias}", "w") as out_file: - print(json.dumps(networks[k], indent = 2), file=out_file) + print(json.dumps(networks[k], indent=2), file=out_file)