diff --git a/stacks-core/README.md b/stacks-core/README.md index 01c75d4..dc001ff 100644 --- a/stacks-core/README.md +++ b/stacks-core/README.md @@ -6,5 +6,4 @@ Folder of composite actions for the [stacks blockchain](https://github.com/stack - [testenv](./testenv) - Configures a workflow with a testing environment - [run-tests](./run-tests) - Run tests with [nextest](https://nexte.st) - [mutation-testing](./mutation-testing) - Run mutation testing -- [create-source-binary](./create-source-binary) - Create the stacks-core binaries for release -- [check-release](./check-release) - Check whether there is a node/signer release or not +- [release](./release) - Actions used in Stacks Core release process diff --git a/stacks-core/check-release/README.md b/stacks-core/check-release/README.md deleted file mode 100644 index a216cd6..0000000 --- a/stacks-core/check-release/README.md +++ /dev/null @@ -1,34 +0,0 @@ -# Check Release action - -Checks whether the tag parsed as argument matches a stacks-node release, a stacks-signer release or no release at all, through regex patterns. - -## Documentation - -### Inputs -| Input | Description | Required | Default | -| ----- | ------------------------------------------- | ----- | -- | -| `tag` | The branch name against which the step runs | false | "" | - -### Outputs -| Output | Description | -| ------------ | -------------------------------------------------------------- | -| `tag` | The release tag, if there is one (empty otherwise). | -| `docker_tag` | The release tag for docker, if there is one (empty otherwise). | -| `is_release` | True if the branch is a release one, false otherwise. | - -## Usage - -```yaml -name: Action -on: pull-request -jobs: - check-packages-and-shards: - name: Check Release - runs-on: ubuntu-latest - steps: - - name: Check Release - id: check_release - uses: stacks-network/actions/stacks-core/check-release@main - with: - tag: "release/2.5.0.0.5-rc6" -``` diff --git a/stacks-core/check-release/action.yml b/stacks-core/check-release/action.yml deleted file mode 100644 index 84d19e9..0000000 --- a/stacks-core/check-release/action.yml +++ /dev/null @@ -1,61 +0,0 @@ -## Composite action to check if the branch is a release tag or not -name: Check Release - -inputs: - tag: - description: "The branch name against which the step runs" - required: false - default: "" - -outputs: - tag: - description: "The release tag, if there is one (empty otherwise)." - value: ${{ steps.check_release.outputs.tag }} - docker_tag: - description: "The release tag for docker, if there is one (empty otherwise)." - value: ${{ steps.check_release.outputs.docker_tag }} - is_release: - description: "True if the branch is a release one, false otherwise." - value: ${{ steps.check_release.outputs.is_release }} - -runs: - using: "composite" - steps: - - name: Set Release Outputs - id: check_release - shell: bash - run: | - branch_name=${{ inputs.tag }} - - stacks_core_version_regex="([0-9].[0-9].[0-9].[0-9].[0-9]+(-rc[0-9]+)?)" # matches x.x.x.x.x || x.x.x.x.x-rcx - signer_version_regex="([0-9].[0-9].[0-9].[0-9].[0-9].[0-9]+(-rc[0-9]+)?)" # matches x.x.x.x.x.x || x.x.x.x.x.x-rcx - - stacks_core_regex_base="release/" - signer_regex_base="release/signer-" - - stacks_core_regex="${stacks_core_regex_base}${stacks_core_version_regex}" - signer_regex="${signer_regex_base}${signer_version_regex}" - - tag="" - docker_tag="" - is_release=false - - if [[ "$branch_name" =~ ^${stacks_core_regex}$ || "$branch_name" =~ ^${signer_regex}$ ]]; then - tag=$(echo "$branch_name" | sed "s|^${stacks_core_regex_base}||g") - case ${branch_name} in - release/signer-[0-9]*) - docker_tag=$(echo "$branch_name" | sed "s|^${signer_regex_base}||g") - is_release=true - ;; - *) - docker_tag=${tag} - is_release=true - ;; - esac - fi - - echo "tag=$tag" >> "$GITHUB_OUTPUT" - echo "docker_tag=$docker_tag" >> "$GITHUB_OUTPUT" - echo "is_release=$is_release" >> "$GITHUB_OUTPUT" - - exit 0 diff --git a/stacks-core/create-source-binary/README.md b/stacks-core/create-source-binary/README.md deleted file mode 100644 index 9e8d012..0000000 --- a/stacks-core/create-source-binary/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Create Source Binary action - -Builds a binary for the given architecture and uploads it to artifacts. - -## Documentation - -### Inputs - -| Input | Description | Required | Default | -| ------ | --------------------------- | -------- | ------- | -| `arch` | Binary's build architecture | `true` | null | -| `tag` | The tag for the release | `true` | null | -| `cpu` | The target CPU | `true` | null | - -## Usage - -```yaml -name: Action -on: push -jobs: - build: - name: Job - runs-on: ubuntu-latest - steps: - - name: Build Binary - id: build_binary - uses: stacks-network/actions/stacks-core/create-source-binary@main - with: - arch: linux-glibc - cpu: x86-64 - tag: 2.4.0.1.0-rc2 -``` diff --git a/stacks-core/release/README.md b/stacks-core/release/README.md new file mode 100644 index 0000000..81075c3 --- /dev/null +++ b/stacks-core/release/README.md @@ -0,0 +1,11 @@ +# Stacks Core release github actions + +Folder of composite actions for the release process of [stacks blockchain](https://github.com/stacks-network/stacks-core) + +- [check-release](./check-release) - Check whether there is a node/signer release or not +- [create-docker-images](./create-docker-images) - Create the docker images for specific `stacks-core` binaries +- [docker-image](./docker-image) - Create and upload a docker image +- [create-github-releases](./create-github-releases) - Create the github releases for specific `stacks-core` binaries +- [create-release](./create-release) - Create and upload a github release +- [create-source-binary](./create-source-binary) - Create the stacks-core binaries for release +- [extract-signer-binary](./extract-signer-binary) - Extract the signer binary from existing `stacks-core` binaries archive diff --git a/stacks-core/release/check-release/README.md b/stacks-core/release/check-release/README.md new file mode 100644 index 0000000..c3abada --- /dev/null +++ b/stacks-core/release/check-release/README.md @@ -0,0 +1,37 @@ +# Check Release action + +Checks whether the tag parsed as argument matches a stacks-node release, a stacks-signer release or no release at all, through regex patterns. + +## Documentation + +### Inputs +| Input | Description | Required | Default | +| ----- | ------------------------------------------- | -------- | ------- | +| `tag` | The branch name against which the step runs | true | | + +### Outputs +| Output | Description | +| ------------------- | --------------------------------------------------------------------- | +| `node_tag` | The node release tag, if there is one (empty otherwise). | +| `node_docker_tag` | The node release tag for docker, if there is one (empty otherwise). | +| `signer_tag` | The signer release tag, if there is one (empty otherwise). | +| `signer_docker_tag` | The signer release tag for docker, if there is one (empty otherwise). | +| `is_node_release` | True if the branch is a node release one, false otherwise. | +| `is_signer_release` | True if the branch is a signer release one, false otherwise. | + +## Usage + +```yaml +name: Action +on: pull-request +jobs: + check-packages-and-shards: + name: Check Release + runs-on: ubuntu-latest + steps: + - name: Check Release + id: check_release + uses: stacks-network/actions/stacks-core/release/check-release@main + with: + tag: "release/2.5.0.0.5-rc6" +``` diff --git a/stacks-core/release/check-release/action.yml b/stacks-core/release/check-release/action.yml new file mode 100644 index 0000000..583a5f7 --- /dev/null +++ b/stacks-core/release/check-release/action.yml @@ -0,0 +1,80 @@ +## Composite action to check if the branch is a release tag or not +name: Check Release + +inputs: + tag: + description: "The branch name against which the step runs" + required: true + +outputs: + node_tag: + description: "The node release tag, if there is one (empty otherwise)." + value: ${{ steps.check_release.outputs.node_tag }} + node_docker_tag: + description: "The node release tag for docker, if there is one (empty otherwise)." + value: ${{ steps.check_release.outputs.node_docker_tag }} + signer_tag: + description: "The signer release tag, if there is one (empty otherwise)." + value: ${{ steps.check_release.outputs.signer_tag }} + signer_docker_tag: + description: "The signer release tag for docker, if there is one (empty otherwise)." + value: ${{ steps.check_release.outputs.signer_docker_tag }} + is_node_release: + description: "True if the branch is a release one, false otherwise." + value: ${{ steps.check_release.outputs.is_node_release }} + is_signer_release: + description: "True if the branch is a release one, false otherwise." + value: ${{ steps.check_release.outputs.is_signer_release }} + +runs: + using: "composite" + steps: + - name: Set Release Outputs + id: check_release + shell: bash + run: | + branch_name=${{ inputs.tag }} + + stacks_core_version_regex="([0-9].[0-9].[0-9].[0-9].[0-9]+(-rc[0-9]+)?)" # matches x.x.x.x.x || x.x.x.x.x-rcx + signer_version_regex="([0-9].[0-9].[0-9].[0-9].[0-9].[0-9]+(-rc[0-9]+)?)" # matches x.x.x.x.x.x || x.x.x.x.x.x-rcx + + stacks_core_regex_base="release/" + signer_regex_base="release/signer-" + + stacks_core_regex="${stacks_core_regex_base}${stacks_core_version_regex}" + signer_regex="${signer_regex_base}${signer_version_regex}" + + node_tag="" + node_docker_tag="" + signer_tag="" + signer_docker_tag="" + is_node_release=false + is_signer_release=false + + case ${branch_name} in + release/signer-[0-9]*) + signer_tag=$(echo "$branch_name" | sed "s|^${stacks_core_regex_base}||g") + signer_docker_tag=$(echo "$branch_name" | sed "s|^${signer_regex_base}||g") + is_signer_release=true + ;; + release/[0-9]*) + node_tag=$(echo "$branch_name" | sed "s|^${stacks_core_regex_base}||g") + node_docker_tag=${node_tag} + signer_tag="signer-$(echo ${node_tag} | sed 's/\(-[^-]*\)*$/.0\1/')" + signer_docker_tag=$(echo ${node_tag} | sed 's/\(-[^-]*\)*$/.0\1/') + is_node_release=true + is_signer_release=true + ;; + *) + exit 1 + ;; + esac + + echo "node_tag=$node_tag" >> "$GITHUB_OUTPUT" + echo "node_docker_tag=$node_docker_tag" >> "$GITHUB_OUTPUT" + echo "signer_tag=$signer_tag" >> "$GITHUB_OUTPUT" + echo "signer_docker_tag=$signer_docker_tag" >> "$GITHUB_OUTPUT" + echo "is_node_release=$is_node_release" >> "$GITHUB_OUTPUT" + echo "is_signer_release=$is_signer_release" >> "$GITHUB_OUTPUT" + + exit 0 diff --git a/stacks-core/release/create-docker-images/README.md b/stacks-core/release/create-docker-images/README.md new file mode 100644 index 0000000..2a57104 --- /dev/null +++ b/stacks-core/release/create-docker-images/README.md @@ -0,0 +1,43 @@ +# Create Docker Images action + +Creates docker images for the node and the signer. + +## Documentation + +### Inputs + +| Input | Description | Required | Default | +| -------------------- | ------------------------------------- | -------- | ------- | +| `node_tag` | Node Release Tag | `true` | null | +| `node_docker_tag` | Node Docker Release Tag | `true` | null | +| `signer_tag` | Signer Release Tag | `true` | null | +| `signer_docker_tag` | Signer Docker Release Tag | `true` | null | +| `is_node_release` | True if it is a node release | `true` | null | +| `is_signer_release` | True if it is a signer release | `true` | null | +| `DOCKERHUB_USERNAME` | Docker username for publishing images | `true` | null | +| `DOCKERHUB_PASSWORD` | Docker password for publishing images | `true` | null | +| `dist` | Linux Distribution to build for | `true` | null | + +## Usage + +```yaml +name: Action +on: push +jobs: + build: + name: Job + runs-on: ubuntu-latest + steps: + - name: Create Docker Images + id: create_docker_images + uses: stacks-network/actions/stacks-core/release/create-docker-images@main + with: + node_tag: 3.0.0.0.1-rc1 + node_docker_tag: 3.0.0.0.1-rc1 + signer_tag: signer-3.0.0.0.1.0-rc1 + signer_docker_tag: 3.0.0.0.1.0-rc1 + is_node_release: 'true' + is_signer_release: 'true' + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} +``` diff --git a/stacks-core/release/create-docker-images/action.yml b/stacks-core/release/create-docker-images/action.yml new file mode 100644 index 0000000..22ce3ed --- /dev/null +++ b/stacks-core/release/create-docker-images/action.yml @@ -0,0 +1,64 @@ +## Github workflow to create and upload github releases +name: Create Releases +description: "Create GitHub Releases" +branding: + icon: "archive" + color: "gray-dark" + +inputs: + node_tag: + description: "Node Release Tag" + required: true + node_docker_tag: + description: "Node Docker Release Tag" + required: true + signer_tag: + description: "Signer Release Tag" + required: true + signer_docker_tag: + description: "Signer Docker Release Tag" + required: true + is_node_release: + description: "True if it is a node release" + required: true + is_signer_release: + description: "True if it is a signer release" + required: true + DOCKERHUB_USERNAME: + description: "Docker username for publishing images" + required: true + DOCKERHUB_PASSWORD: + description: "Docker password for publishing images" + required: true + dist: + description: "Linux Distribution to build for" + required: true + +runs: + using: "composite" + steps: + ## Creates the node docker image + - name: Create Node Docker Image + if: | + inputs.is_node_release == 'true' + id: create_node_release + uses: stacks-network/actions/stacks-core/release/docker-image@main + with: + tag: ${{ inputs.node_tag }} + docker_tag: ${{ inputs.node_docker_tag }} + DOCKERHUB_USERNAME: ${{ inputs.DOCKERHUB_USERNAME }} + DOCKERHUB_PASSWORD: ${{ inputs.DOCKERHUB_PASSWORD }} + dist: ${{ inputs.dist }} + + ## Creates the signer docker image + - name: Create Signer Docker Image + if: | + inputs.is_signer_release == 'true' + id: create_signer_release + uses: stacks-network/actions/stacks-core/release/docker-image@main + with: + tag: ${{ inputs.signer_tag }} + docker_tag: ${{ inputs.signer_docker_tag }} + DOCKERHUB_USERNAME: ${{ inputs.DOCKERHUB_USERNAME }} + DOCKERHUB_PASSWORD: ${{ inputs.DOCKERHUB_PASSWORD }} + dist: ${{ inputs.dist }} \ No newline at end of file diff --git a/stacks-core/release/create-github-releases/README.md b/stacks-core/release/create-github-releases/README.md new file mode 100644 index 0000000..f6e6c75 --- /dev/null +++ b/stacks-core/release/create-github-releases/README.md @@ -0,0 +1,40 @@ +# Create Github Releases action + +Creates github releases for the node and the signer. + +## Documentation + +### Inputs + +| Input | Description | Required | Default | +| -------------------- | ------------------------------ | -------- | ------- | +| `node_tag` | Node Release Tag | `true` | null | +| `node_docker_tag` | Node Docker Release Tag | `true` | null | +| `signer_tag` | Signer Release Tag | `true` | null | +| `signer_docker_tag` | Signer Docker Release Tag | `true` | null | +| `is_node_release` | True if it is a node release | `true` | null | +| `is_signer_release` | True if it is a signer release | `true` | null | +| `GH_TOKEN` | GitHub Token | `true` | null | + +## Usage + +```yaml +name: Action +on: push +jobs: + build: + name: Job + runs-on: ubuntu-latest + steps: + - name: Create Github Releases + id: create_github_releases + uses: stacks-network/actions/stacks-core/release/create-github-releases@main + with: + node_tag: 3.0.0.0.1-rc1 + node_docker_tag: 3.0.0.0.1-rc1 + signer_tag: signer-3.0.0.0.1.0-rc1 + signer_docker_tag: 3.0.0.0.1.0-rc1 + is_node_release: 'true' + is_signer_release: 'true' + GH_TOKEN: ${{ secrets.GH_TOKEN }} +``` diff --git a/stacks-core/release/create-github-releases/action.yml b/stacks-core/release/create-github-releases/action.yml new file mode 100644 index 0000000..cca4d20 --- /dev/null +++ b/stacks-core/release/create-github-releases/action.yml @@ -0,0 +1,54 @@ +## Github workflow to create and upload github releases +name: Create Releases +description: "Create GitHub Releases" +branding: + icon: "archive" + color: "gray-dark" + +inputs: + node_tag: + description: "Node Release Tag" + required: true + node_docker_tag: + description: "Node Docker Release Tag" + required: true + signer_tag: + description: "Signer Release Tag" + required: true + signer_docker_tag: + description: "Signer Docker Release Tag" + required: true + is_node_release: + description: "True if it is a node release" + required: true + is_signer_release: + description: "True if it is a signer release" + required: true + GH_TOKEN: + description: "GitHub Token" + required: true + +runs: + using: "composite" + steps: + ## Creates the node release + - name: Create Node Release + if: | + inputs.is_node_release == 'true' + id: create_node_release + uses: stacks-network/actions/stacks-core/release/create-release@main + with: + tag: ${{ inputs.node_tag }} + docker_tag: ${{ inputs.node_docker_tag }} + GH_TOKEN: ${{ inputs.GH_TOKEN }} + + ## Creates the signer release + - name: Create Signer Release + if: | + inputs.is_signer_release == 'true' + id: create_signer_release + uses: stacks-network/actions/stacks-core/release/create-release@main + with: + tag: ${{ inputs.signer_tag }} + docker_tag: ${{ inputs.signer_docker_tag }} + GH_TOKEN: ${{ inputs.GH_TOKEN }} \ No newline at end of file diff --git a/stacks-core/release/create-release/README.md b/stacks-core/release/create-release/README.md new file mode 100644 index 0000000..205659e --- /dev/null +++ b/stacks-core/release/create-release/README.md @@ -0,0 +1,32 @@ +# Create Release action + +Creates a github release for the given tag. + +## Documentation + +### Inputs + +| Input | Description | Required | Default | +| ------------ | ------------------ | -------- | ------- | +| `tag` | Release Tag | `true` | null | +| `docker_tag` | Release Docker Tag | `true` | null | +| `GH_TOKEN` | GitHub Token | `true` | null | + +## Usage + +```yaml +name: Action +on: push +jobs: + build: + name: Job + runs-on: ubuntu-latest + steps: + - name: Create Release + id: create_release + uses: stacks-network/actions/stacks-core/release/create-release@main + with: + tag: signer-3.0.0.0.1.0-rc1 + docker_tag: 3.0.0.0.1.0-rc1 + GH_TOKEN: ${{ inputs.GH_TOKEN }} +``` diff --git a/stacks-core/release/create-release/action.yml b/stacks-core/release/create-release/action.yml new file mode 100644 index 0000000..2a59936 --- /dev/null +++ b/stacks-core/release/create-release/action.yml @@ -0,0 +1,54 @@ +## Github workflow to create and upload a github release +name: Create Release +description: "Create GitHub Release" +branding: + icon: "archive" + color: "gray-dark" + +inputs: + tag: + description: "Release Tag" + required: true + docker_tag: + description: "Release Docker Tag" + required: true + GH_TOKEN: + description: "GitHub Token" + required: true + +runs: + using: "composite" + steps: + ## Downloads the artifacts built in `create-source-binary` + - name: Download Artifacts + id: download_artifacts + uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + with: + pattern: ${{ inputs.docker_tag }}-binary-build-* + path: release + merge-multiple: true + + ## Generate a checksums file to be added to the release page + - name: Generate Checksums + id: generate_checksum + uses: stacks-network/actions/generate-checksum@main + with: + artifact_download_pattern: "${{ inputs.docker_tag }}-binary-build-*" + + ## Upload the release archives with the checksums file + - name: Upload Release + id: upload_release + uses: softprops/action-gh-release@69320dbe05506a9a39fc8ae11030b214ec2d1f87 #v2.0.5 + env: + GITHUB_TOKEN: ${{ inputs.GH_TOKEN }} + with: + name: Release ${{ inputs.tag || github.ref }} + tag_name: ${{ inputs.tag || github.ref }} + draft: false + prerelease: true + fail_on_unmatched_files: true + target_commitish: ${{ github.sha }} + generate_release_notes: true + files: | + release/*.zip + CHECKSUMS.txt diff --git a/stacks-core/release/create-source-binary/README.md b/stacks-core/release/create-source-binary/README.md new file mode 100644 index 0000000..276ff52 --- /dev/null +++ b/stacks-core/release/create-source-binary/README.md @@ -0,0 +1,38 @@ +# Create Source Binary action + +Builds the binaries for the given architecture and uploads it to artifacts. In case of signer releases, it also uploads the standalone signer binary to artifacts. + +## Documentation + +### Inputs + +| Input | Description | Required | Default | +| ------------------- | ---------------------------- | -------- | ------- | +| `arch` | Binary's build architecture | `true` | null | +| `cpu` | The target CPU | `true` | null | +| `node_tag` | Node Release Tag | `true` | null | +| `signer_tag` | Signer Release Tag | `true` | null | +| `signer_docker_tag` | Signer Docker Release Tag | `true` | null | +| `is_node_release` | True if it is a node release | `true` | null | + +## Usage + +```yaml +name: Action +on: push +jobs: + build: + name: Job + runs-on: ubuntu-latest + steps: + - name: Build Binary + id: build_binary + uses: stacks-network/actions/stacks-core/release/create-source-binary@main + with: + arch: linux-glibc + cpu: x86-64 + node_tag: 2.4.0.1.0-rc2 + signer_tag: signer-2.4.0.1.0-rc2 + signer_docker_tag: 2.4.0.1.0.0-rc2 + is_node_release: 'true' +``` diff --git a/stacks-core/create-source-binary/action.yml b/stacks-core/release/create-source-binary/action.yml similarity index 74% rename from stacks-core/create-source-binary/action.yml rename to stacks-core/release/create-source-binary/action.yml index 4f7edfc..b68bf14 100644 --- a/stacks-core/create-source-binary/action.yml +++ b/stacks-core/release/create-source-binary/action.yml @@ -12,8 +12,17 @@ inputs: cpu: description: "CPU to build binary" required: true - tag: - description: "Release Tag" + node_tag: + description: "Node Release Tag" + required: true + signer_tag: + description: "Signer Release Tag" + required: true + signer_docker_tag: + description: "Signer Docker Release Tag" + required: true + is_node_release: + description: "True if it is a node release" required: true runs: @@ -72,12 +81,12 @@ runs: file: ${{ github.action_path }}/build-scripts/${{ env.DOCKERFILE }} outputs: type=local,dest=./release/${{ inputs.arch }} build-args: | - STACKS_NODE_VERSION=${{ inputs.tag || env.GITHUB_SHA_SHORT }} + STACKS_NODE_VERSION=${{ inputs.node_tag || inputs.signer_docker_tag || env.GITHUB_SHA_SHORT }} OS_ARCH=${{ inputs.arch }} TARGET_CPU=${{ env.TARGET_CPU }} GIT_BRANCH=${{ env.GITHUB_REF_SHORT }} GIT_COMMIT=${{ env.GITHUB_SHA_SHORT }} - TAG=${{ inputs.tag }} + TAG=${{ inputs.node_tag || inputs.signer_tag }} ## Compress the binary artifact - name: Compress artifact @@ -91,5 +100,17 @@ runs: id: upload_artifact uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 with: - name: ${{ inputs.tag }}-binary-build-${{ env.ZIPFILE }} + name: ${{ inputs.node_tag || inputs.signer_docker_tag }}-binary-build-${{ env.ZIPFILE }} path: ${{ env.ZIPFILE }}.zip + + ## Extract the signer binaries from the previously built node archives + - name: Extract signer binary + if: | + inputs.is_node_release == 'true' + id: extract_signer_binary + uses: stacks-network/actions/stacks-core/release/extract-signer-binary@main + with: + arch: ${{ inputs.arch }} + cpu: ${{ inputs.cpu }} + signer_docker_tag: ${{ inputs.signer_docker_tag }} + node_tag: ${{ inputs.node_tag }} diff --git a/stacks-core/create-source-binary/build-scripts/Dockerfile.linux-glibc-arm64 b/stacks-core/release/create-source-binary/build-scripts/Dockerfile.linux-glibc-arm64 similarity index 57% rename from stacks-core/create-source-binary/build-scripts/Dockerfile.linux-glibc-arm64 rename to stacks-core/release/create-source-binary/build-scripts/Dockerfile.linux-glibc-arm64 index 43a24ea..2c8e581 100644 --- a/stacks-core/create-source-binary/build-scripts/Dockerfile.linux-glibc-arm64 +++ b/stacks-core/release/create-source-binary/build-scripts/Dockerfile.linux-glibc-arm64 @@ -24,10 +24,16 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ BUILD_ARG="" \ ;; \ esac \ - && CC=aarch64-linux-gnu-gcc \ - CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \ - CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ - cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} ${BUILD_ARG} \ + && export CC=aarch64-linux-gnu-gcc \ + && export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \ + && export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ + && cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} ${BUILD_ARG} \ + # Conditionally rebuild `stacks-signer` if GIT_BRANCH does NOT contain "signer" + && if echo "${GIT_BRANCH}" | grep -vq "signer"; then \ + STACKS_NODE_VERSION="${STACKS_NODE_VERSION}.0"; \ + cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-signer; \ + fi \ + # End conditional && mkdir -p /out \ && find ${BUILD_DIR}/target/${TARGET}/release/ -maxdepth 1 -executable -type f | xargs cp -at /out/ diff --git a/stacks-core/create-source-binary/build-scripts/Dockerfile.linux-glibc-armv7 b/stacks-core/release/create-source-binary/build-scripts/Dockerfile.linux-glibc-armv7 similarity index 56% rename from stacks-core/create-source-binary/build-scripts/Dockerfile.linux-glibc-armv7 rename to stacks-core/release/create-source-binary/build-scripts/Dockerfile.linux-glibc-armv7 index 6a7cca8..b3c42ba 100644 --- a/stacks-core/create-source-binary/build-scripts/Dockerfile.linux-glibc-armv7 +++ b/stacks-core/release/create-source-binary/build-scripts/Dockerfile.linux-glibc-armv7 @@ -24,10 +24,16 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ BUILD_ARG="" \ ;; \ esac \ - && CC=arm-linux-gnueabihf-gcc \ - CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \ - CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \ - cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} ${BUILD_ARG} \ + && export CC=arm-linux-gnueabihf-gcc \ + && export CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \ + && export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \ + && cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} ${BUILD_ARG} \ + # Conditionally rebuild `stacks-signer` if GIT_BRANCH does NOT contain "signer" + && if echo "${GIT_BRANCH}" | grep -vq "signer"; then \ + STACKS_NODE_VERSION="${STACKS_NODE_VERSION}.0"; \ + cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-signer; \ + fi \ + # End conditional && mkdir -p /out \ && find ${BUILD_DIR}/target/${TARGET}/release/ -maxdepth 1 -executable -type f | xargs cp -at /out/ diff --git a/stacks-core/create-source-binary/build-scripts/Dockerfile.linux-glibc-x64 b/stacks-core/release/create-source-binary/build-scripts/Dockerfile.linux-glibc-x64 similarity index 76% rename from stacks-core/create-source-binary/build-scripts/Dockerfile.linux-glibc-x64 rename to stacks-core/release/create-source-binary/build-scripts/Dockerfile.linux-glibc-x64 index 1b1fc68..3eb0aa1 100644 --- a/stacks-core/create-source-binary/build-scripts/Dockerfile.linux-glibc-x64 +++ b/stacks-core/release/create-source-binary/build-scripts/Dockerfile.linux-glibc-x64 @@ -28,6 +28,12 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ ;; \ esac \ && cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} ${BUILD_ARG} \ + # Conditionally rebuild `stacks-signer` if GIT_BRANCH does NOT contain "signer" + && if echo "${GIT_BRANCH}" | grep -vq "signer"; then \ + STACKS_NODE_VERSION="${STACKS_NODE_VERSION}.0"; \ + cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-signer; \ + fi \ + # End conditional && mkdir -p /out \ && find ${BUILD_DIR}/target/${TARGET}/release/ -maxdepth 1 -executable -type f | xargs cp -at /out/ diff --git a/stacks-core/create-source-binary/build-scripts/Dockerfile.linux-musl-arm64 b/stacks-core/release/create-source-binary/build-scripts/Dockerfile.linux-musl-arm64 similarity index 72% rename from stacks-core/create-source-binary/build-scripts/Dockerfile.linux-musl-arm64 rename to stacks-core/release/create-source-binary/build-scripts/Dockerfile.linux-musl-arm64 index 8510a75..604d12c 100644 --- a/stacks-core/create-source-binary/build-scripts/Dockerfile.linux-musl-arm64 +++ b/stacks-core/release/create-source-binary/build-scripts/Dockerfile.linux-musl-arm64 @@ -23,6 +23,12 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ ;; \ esac \ && cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} ${BUILD_ARG} \ + # Conditionally rebuild `stacks-signer` if GIT_BRANCH does NOT contain "signer" + && if echo "${GIT_BRANCH}" | grep -vq "signer"; then \ + STACKS_NODE_VERSION="${STACKS_NODE_VERSION}.0"; \ + cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-signer; \ + fi \ + # End conditional && mkdir -p /out \ && find ${BUILD_DIR}/target/${TARGET}/release/ -maxdepth 1 -executable -type f | xargs cp -at /out/ diff --git a/stacks-core/create-source-binary/build-scripts/Dockerfile.linux-musl-armv7 b/stacks-core/release/create-source-binary/build-scripts/Dockerfile.linux-musl-armv7 similarity index 72% rename from stacks-core/create-source-binary/build-scripts/Dockerfile.linux-musl-armv7 rename to stacks-core/release/create-source-binary/build-scripts/Dockerfile.linux-musl-armv7 index 54b7b49..2a75e3e 100644 --- a/stacks-core/create-source-binary/build-scripts/Dockerfile.linux-musl-armv7 +++ b/stacks-core/release/create-source-binary/build-scripts/Dockerfile.linux-musl-armv7 @@ -23,6 +23,12 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ ;; \ esac \ && cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} ${BUILD_ARG} \ + # Conditionally rebuild `stacks-signer` if GIT_BRANCH does NOT contain "signer" + && if echo "${GIT_BRANCH}" | grep -vq "signer"; then \ + STACKS_NODE_VERSION="${STACKS_NODE_VERSION}.0"; \ + cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-signer; \ + fi \ + # End conditional && mkdir -p /out \ && find ${BUILD_DIR}/target/${TARGET}/release/ -maxdepth 1 -executable -type f | xargs cp -at /out/ diff --git a/stacks-core/create-source-binary/build-scripts/Dockerfile.linux-musl-x64 b/stacks-core/release/create-source-binary/build-scripts/Dockerfile.linux-musl-x64 similarity index 74% rename from stacks-core/create-source-binary/build-scripts/Dockerfile.linux-musl-x64 rename to stacks-core/release/create-source-binary/build-scripts/Dockerfile.linux-musl-x64 index 42980a2..3e375ce 100644 --- a/stacks-core/create-source-binary/build-scripts/Dockerfile.linux-musl-x64 +++ b/stacks-core/release/create-source-binary/build-scripts/Dockerfile.linux-musl-x64 @@ -27,6 +27,12 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ ;; \ esac \ && cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} ${BUILD_ARG} \ + # Conditionally rebuild `stacks-signer` if GIT_BRANCH does NOT contain "signer" + && if echo "${GIT_BRANCH}" | grep -vq "signer"; then \ + STACKS_NODE_VERSION="${STACKS_NODE_VERSION}.0"; \ + cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-signer; \ + fi \ + # End conditional && mkdir -p /out \ && find ${BUILD_DIR}/target/${TARGET}/release/ -maxdepth 1 -executable -type f | xargs cp -at /out/ diff --git a/stacks-core/create-source-binary/build-scripts/Dockerfile.macos-arm64 b/stacks-core/release/create-source-binary/build-scripts/Dockerfile.macos-arm64 similarity index 78% rename from stacks-core/create-source-binary/build-scripts/Dockerfile.macos-arm64 rename to stacks-core/release/create-source-binary/build-scripts/Dockerfile.macos-arm64 index 89b4c00..23bb6d2 100644 --- a/stacks-core/create-source-binary/build-scripts/Dockerfile.macos-arm64 +++ b/stacks-core/release/create-source-binary/build-scripts/Dockerfile.macos-arm64 @@ -31,6 +31,12 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ ;; \ esac \ && cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} ${BUILD_ARG} \ + # Conditionally rebuild `stacks-signer` if GIT_BRANCH does NOT contain "signer" + && if echo "${GIT_BRANCH}" | grep -vq "signer"; then \ + STACKS_NODE_VERSION="${STACKS_NODE_VERSION}.0"; \ + cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-signer; \ + fi \ + # End conditional && mkdir -p /out \ && find ${BUILD_DIR}/target/${TARGET}/release/ -maxdepth 1 -executable -type f | xargs cp -at /out/ diff --git a/stacks-core/create-source-binary/build-scripts/Dockerfile.macos-x64 b/stacks-core/release/create-source-binary/build-scripts/Dockerfile.macos-x64 similarity index 79% rename from stacks-core/create-source-binary/build-scripts/Dockerfile.macos-x64 rename to stacks-core/release/create-source-binary/build-scripts/Dockerfile.macos-x64 index 1f554b4..62e05ff 100644 --- a/stacks-core/create-source-binary/build-scripts/Dockerfile.macos-x64 +++ b/stacks-core/release/create-source-binary/build-scripts/Dockerfile.macos-x64 @@ -33,6 +33,12 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ ;; \ esac \ && cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} ${BUILD_ARG} \ + # Conditionally rebuild `stacks-signer` if GIT_BRANCH does NOT contain "signer" + && if echo "${GIT_BRANCH}" | grep -vq "signer"; then \ + STACKS_NODE_VERSION="${STACKS_NODE_VERSION}.0"; \ + cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-signer; \ + fi \ + # End conditional && mkdir -p /out \ && find ${BUILD_DIR}/target/${TARGET}/release/ -maxdepth 1 -executable -type f | xargs cp -at /out/ diff --git a/stacks-core/create-source-binary/build-scripts/Dockerfile.windows-x64 b/stacks-core/release/create-source-binary/build-scripts/Dockerfile.windows-x64 similarity index 61% rename from stacks-core/create-source-binary/build-scripts/Dockerfile.windows-x64 rename to stacks-core/release/create-source-binary/build-scripts/Dockerfile.windows-x64 index 0e4b599..380a093 100644 --- a/stacks-core/create-source-binary/build-scripts/Dockerfile.windows-x64 +++ b/stacks-core/release/create-source-binary/build-scripts/Dockerfile.windows-x64 @@ -26,9 +26,15 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ BUILD_ARG="" \ ;; \ esac \ - && CC_x86_64_pc_windows_gnu=x86_64-w64-mingw32-gcc \ - CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc \ - cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} ${BUILD_ARG} \ + && export CC_x86_64_pc_windows_gnu=x86_64-w64-mingw32-gcc \ + && export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc \ + && cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} ${BUILD_ARG} \ + # Conditionally rebuild `stacks-signer` if GIT_BRANCH does NOT contain "signer" + && if echo "${GIT_BRANCH}" | grep -vq "signer"; then \ + STACKS_NODE_VERSION="${STACKS_NODE_VERSION}.0"; \ + cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-signer; \ + fi \ + # End conditional && mkdir -p /out \ && find ${BUILD_DIR}/target/${TARGET}/release/ -maxdepth 1 -executable -type f | xargs cp -at /out/ diff --git a/stacks-core/release/docker-image/README.md b/stacks-core/release/docker-image/README.md new file mode 100644 index 0000000..ce51be0 --- /dev/null +++ b/stacks-core/release/docker-image/README.md @@ -0,0 +1,35 @@ +# Docker Image action + +Creates a docker image for the given tag and uploads it to dockerhub. + +## Documentation + +### Inputs + +| Input | Description | Required | Default | +| -------------------- | ------------------------------------- | -------- | ------- | +| `tag` | Version tag of release | `true` | null | +| `docker_tag` | Version tag for docker images | `true` | null | +| `DOCKERHUB_USERNAME` | Docker username for publishing images | `true` | null | +| `DOCKERHUB_PASSWORD` | Docker password for publishing images | `true` | null | +| `dist` | Linux Distribution to build for | `true` | null | + +## Usage + +```yaml +name: Action +on: push +jobs: + build: + name: Job + runs-on: ubuntu-latest + steps: + - name: Docker Image + id: docker_image + uses: stacks-network/actions/stacks-core/release/docker-image@main + with: + tag: signer-3.0.0.0.1.0-rc1 + docker_tag: 3.0.0.0.1.0-rc1 + DOCKERHUB_USERNAME: ${{ inputs.DOCKERHUB_USERNAME }} + DOCKERHUB_PASSWORD: ${{ inputs.DOCKERHUB_PASSWORD }} +``` diff --git a/stacks-core/release/docker-image/action.yml b/stacks-core/release/docker-image/action.yml new file mode 100644 index 0000000..6b8f772 --- /dev/null +++ b/stacks-core/release/docker-image/action.yml @@ -0,0 +1,138 @@ +## Github workflow to create and upload github releases +name: Docker Image +description: "Create Docker Image" +branding: + icon: "archive" + color: "gray-dark" + +inputs: + tag: + description: "Version tag of release" + required: true + docker_tag: + description: "Version tag for docker images" + required: true + DOCKERHUB_USERNAME: + description: "Docker username for publishing images" + required: true + DOCKERHUB_PASSWORD: + description: "Docker password for publishing images" + required: true + dist: + description: "Linux Distribution to build for" + required: true + +runs: + using: "composite" + steps: + ## Setup Docker for the builds + - name: Docker setup + id: docker_setup + uses: stacks-network/actions/docker@main + with: + username: ${{ inputs.DOCKERHUB_USERNAME }} + password: ${{ inputs.DOCKERHUB_PASSWORD }} + + ## if the repo owner is not `stacks-network`, default to a docker-org of the repo owner (i.e. github user id) + ## this allows forks to run the docker push workflows without having to hardcode a dockerhub org (but it does require docker hub user to match github username) + - name: Set Local env vars + id: set_env + if: | + github.repository_owner != 'stacks-network' + shell: bash + run: | + echo "docker-org=${{ github.repository_owner }}" >> "$GITHUB_ENV" + + - name: Check Signer Release + id: check_signer_release + shell: bash + run: | + case "${{ inputs.tag }}" in + signer-*) + echo "is-signer-release=true" >> $GITHUB_ENV + ;; + *) + echo "is-signer-release=false" >> $GITHUB_ENV + ;; + esac + + - name: Set Docker Tag RC Flag + id: docker_tag_rc_flag + shell: bash + run: | + if [[ "${{ inputs.docker_tag }}" =~ -rc[0-9]*$ ]]; then + echo "docker_tag_rc=true" >> $GITHUB_ENV + else + echo "docker_tag_rc=false" >> $GITHUB_ENV + fi + + ## Set docker metatdata + ## - depending on the matrix.dist, different tags will be enabled + ## ex. debian will have this tag: `type=ref,event=tag,enable=${{ matrix.dist == 'debian' }}` + - name: Docker Metadata ( ${{matrix.dist}} ) + if: ${{ env.is-signer-release == 'true' }} + id: docker_metadata_signer + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 #v5.5.1 + with: + images: | + ${{env.docker-org}}/stacks-signer + tags: | + type=raw,value=latest,enable=${{ inputs.docker_tag != '' && env.docker_tag_rc != 'true' && matrix.dist == 'debian' }} + type=raw,value=${{ inputs.docker_tag }}-${{ matrix.dist }},enable=${{ inputs.docker_tag != '' && matrix.dist == 'debian'}} + type=raw,value=${{ inputs.docker_tag }},enable=${{ inputs.docker_tag != '' && matrix.dist == 'debian' }} + type=ref,event=tag,enable=${{ matrix.dist == 'debian' }} + type=raw,value=latest-${{ matrix.dist }},enable=${{ inputs.docker_tag != '' && env.docker_tag_rc != 'true' && matrix.dist == 'alpine' }} + type=raw,value=${{ inputs.docker_tag }}-${{ matrix.dist }},enable=${{ inputs.docker_tag != '' && matrix.dist == 'alpine' }} + + - name: Docker Metadata ( ${{matrix.dist}} ) + if: ${{ env.is-signer-release == 'false' }} + id: docker_metadata_node + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 #v5.5.1 + with: + ## tag images with current repo name `stacks-core` as well as legacy `stacks-blockchain` + images: | + ${{env.docker-org}}/${{ github.event.repository.name }} + ${{env.docker-org}}/stacks-blockchain + tags: | + type=raw,value=latest,enable=${{ inputs.docker_tag != '' && env.docker_tag_rc != 'true' && matrix.dist == 'debian' }} + type=raw,value=${{ inputs.docker_tag }}-${{ matrix.dist }},enable=${{ inputs.docker_tag != '' && matrix.dist == 'debian'}} + type=raw,value=${{ inputs.docker_tag }},enable=${{ inputs.docker_tag != '' && matrix.dist == 'debian' }} + type=ref,event=tag,enable=${{ matrix.dist == 'debian' }} + type=raw,value=latest-${{ matrix.dist }},enable=${{ inputs.docker_tag != '' && env.docker_tag_rc != 'true' && matrix.dist == 'alpine' }} + type=raw,value=${{ inputs.docker_tag }}-${{ matrix.dist }},enable=${{ inputs.docker_tag != '' && matrix.dist == 'alpine' }} + + ## Build docker image for signer release + - name: Build and Push ( ${{matrix.dist}} ) + if: ${{ env.is-signer-release == 'true' }} + id: docker_build_signer + uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 + with: + file: ./.github/actions/dockerfiles/Dockerfile.${{ matrix.dist }}-binary + platforms: ${{ env.docker_platforms }} + tags: ${{ steps.docker_metadata_signer.outputs.tags }} + labels: ${{ steps.docker_metadata_signer.outputs.labels }} + build-args: | + TAG=${{ inputs.tag }} + REPO=${{ github.repository_owner }}/${{ github.event.repository.name }} + STACKS_NODE_VERSION=${{ inputs.tag || env.GITHUB_SHA_SHORT }} + GIT_BRANCH=${{ env.GITHUB_REF_SHORT }} + GIT_COMMIT=${{ env.GITHUB_SHA_SHORT }} + push: ${{ env.DOCKER_PUSH }} + + ## Build docker image for node release + - name: Build and Push ( ${{matrix.dist}} ) + if: ${{ env.is-signer-release == 'false' }} + id: docker_build_node + uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 + with: + file: ./.github/actions/dockerfiles/Dockerfile.${{ matrix.dist }}-binary + platforms: ${{ env.docker_platforms }} + tags: ${{ steps.docker_metadata_node.outputs.tags }} + labels: ${{ steps.docker_metadata_node.outputs.labels }} + build-args: | + TAG=${{ inputs.tag }} + REPO=${{ github.repository_owner }}/${{ github.event.repository.name }} + STACKS_NODE_VERSION=${{ inputs.tag || env.GITHUB_SHA_SHORT }} + GIT_BRANCH=${{ env.GITHUB_REF_SHORT }} + GIT_COMMIT=${{ env.GITHUB_SHA_SHORT }} + push: ${{ env.DOCKER_PUSH }} \ No newline at end of file diff --git a/stacks-core/release/extract-signer-binary/README.md b/stacks-core/release/extract-signer-binary/README.md new file mode 100644 index 0000000..d49e945 --- /dev/null +++ b/stacks-core/release/extract-signer-binary/README.md @@ -0,0 +1,34 @@ +# Extract Signer Binary action + +Extracts the signer binary for the given architecture from the existing archives, then uploads it to artifacts. + +## Documentation + +### Inputs + +| Input | Description | Required | Default | +| ------------------- | -------------------------------------- | -------- | ------- | +| `arch` | Binary's build architecture | `true` | null | +| `cpu` | The target CPU | `true` | null | +| `signer_docker_tag` | Signer Docker Release Tag | `true` | null | +| `node_tag` | The artifact pattern of the node cache | `true` | null | + +## Usage + +```yaml +name: Action +on: push +jobs: + build: + name: Job + runs-on: ubuntu-latest + steps: + - name: Extract Signer Binary + id: extract_signer_binary + uses: stacks-network/actions/stacks-core/release/extract-signer-binary@main + with: + arch: linux-glibc + cpu: x86-64 + signer_docker_tag: 3.0.0.0.1.0-rc1 + node_tag: 3.0.0.0.1-rc1 +``` diff --git a/stacks-core/release/extract-signer-binary/action.yml b/stacks-core/release/extract-signer-binary/action.yml new file mode 100644 index 0000000..513a8a9 --- /dev/null +++ b/stacks-core/release/extract-signer-binary/action.yml @@ -0,0 +1,76 @@ +## Github workflow to create multiarch binaries from source +name: Create Binaries +description: "Create Binary Archives" +branding: + icon: "archive" + color: "gray-dark" + +inputs: + arch: + description: "Architecture to build binary" + required: true + cpu: + description: "CPU to build binary" + required: true + signer_docker_tag: + description: "Signer Docker Release Tag" + required: true + node_tag: + description: "The artifact pattern of the node cache" + required: true + +runs: + using: "composite" + steps: + ## Set env vars based on the type of arch build + - name: Set local env vars + id: set_env + shell: bash + run: | + case ${{ inputs.cpu }} in + x86-64) + ## default x64 builds to use v3 variant. + ARCHIVE_NAME="x64" + ;; + x86-64-v2) + ## intel nehalem (2008) and newer + ARCHIVE_NAME="x64-v2" + ;; + x86-64-v3) + ## intel haswell (2013) and newer + ARCHIVE_NAME="x64-v3" + ;; + x86-64-v4) + ## intel skylake (2017) and newer + ARCHIVE_NAME="x64-v4" + ;; + *) + ARCHIVE_NAME="${{ inputs.cpu }}" + ;; + esac + echo "ZIPFILE=${{ inputs.arch }}-${ARCHIVE_NAME}" >> "$GITHUB_ENV" + echo "CACHE_NAME=${{ inputs.node_tag }}-binary-build-${{ inputs.arch }}-${ARCHIVE_NAME}" >> "$GITHUB_ENV" + + ## Downloads the artifacts built in `create-source-binary.yml` + - name: Download Artifacts + id: download_artifacts + uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + with: + pattern: ${{ env.CACHE_NAME }} + path: release + merge-multiple: true + + ## Remove everything but the signer from the archive + - name: Remove binaries + id: remove_binaries + shell: bash + run: | + zipinfo -1 ./release/${{ env.ZIPFILE }}.zip | grep -v 'stacks-signer' | xargs -I {} zip -d ./release/${{ env.ZIPFILE }}.zip "{}" + + ## Upload the binary artifact to the github action (used in `github-release.yml` to create a release) + - name: Upload artifact + id: upload_artifact + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + with: + name: ${{ inputs.signer_docker_tag }}-binary-build-${{ env.ZIPFILE }} + path: ./release/${{ env.ZIPFILE }}.zip