Skip to content

chore: tx-submit-api 0.20.0 (#149) #36

chore: tx-submit-api 0.20.0 (#149)

chore: tx-submit-api 0.20.0 (#149) #36

Workflow file for this run

---
# The below is copied from the following URL and modified slightly
# https://dev.to/imjoseangel/release-and-deploy-ansible-collection-with-github-actions-4a62
name: Release and Deploy collection
on:
# Trigger on change to galaxy.yml in main branch
push:
tags:
- 'v*.*.*'
jobs:
create-draft-release:
runs-on: ubuntu-latest
outputs:
RELEASE_ID: ${{ steps.create-release.outputs.result }}
steps:
- run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"
- uses: actions/github-script@v7
id: create-release
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
try {
const response = await github.rest.repos.createRelease({
draft: true,
generate_release_notes: true,
name: process.env.RELEASE_TAG,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: process.env.RELEASE_TAG,
});
return response.data.id;
} catch (error) {
core.setFailed(error.message);
}
build-publish-collection:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9]
needs: [create-draft-release]
steps:
- run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"
- run: "echo \"ARTIFACT_TAG=${GITHUB_REF#refs/tags/v}\" >> $GITHUB_ENV"
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade ansible
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Replace version in galaxy.yml
run: |
sed -i "s/^version: .*/version: ${{ env.ARTIFACT_TAG }}/" galaxy.yml
- name: Build Ansible Collection
run: ansible-galaxy collection build --force
- name: Upload release asset
run: |
_filename=blinklabs-cardano-${{ env.ARTIFACT_TAG }}.tar.gz
curl \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/tar+gzip" \
--data-binary @${_filename} \
https://uploads.github.com/repos/${{ github.repository }}/releases/${{ needs.create-draft-release.outputs.RELEASE_ID }}/assets?name=${_filename}
- name: Publish Ansible collection to Galaxy
run: ansible-galaxy collection publish blinklabs-cardano-${{ env.ARTIFACT_TAG }}.tar.gz --api-key ${{ secrets.GALAXY_API_KEY }}
finalize-release:
runs-on: ubuntu-latest
needs: [create-draft-release, build-publish-collection]
steps:
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ needs.create-draft-release.outputs.RELEASE_ID }},
draft: false,
});
} catch (error) {
core.setFailed(error.message);
}