Skip to content

Commit

Permalink
ci: switch to tag-based publishing (#99)
Browse files Browse the repository at this point in the history
Fixes #58
  • Loading branch information
agaffney authored Jul 17, 2024
1 parent 3f09867 commit efd1d85
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
35 changes: 13 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,18 @@

name: Release and Deploy collection
on:
# Allow manual triggering for testing
workflow_dispatch:
# Trigger on change to galaxy.yml in main branch
push:
branches:
- main
paths:
- galaxy.yml
tags:
- 'v*.*.*'

jobs:
create-draft-release:
runs-on: ubuntu-latest
outputs:
RELEASE_ID: ${{ steps.create-release.outputs.result }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Get current version
id: cversion
run: echo "::set-output name=version::$(grep version galaxy.yml | sed -e 's:^.* ::')"
- run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"

- uses: actions/github-script@v6
id: create-release
Expand All @@ -36,11 +27,11 @@ jobs:
const response = await github.rest.repos.createRelease({
draft: true,
generate_release_notes: true,
name: '${{ steps.cversion.outputs.version }}',
name: process.env.RELEASE_TAG,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: '${{ steps.cversion.outputs.version }}',
tag_name: process.env.RELEASE_TAG,
});
return response.data.id;
Expand All @@ -55,12 +46,8 @@ jobs:
python-version: [3.9]
needs: [create-draft-release]
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Get current version
id: cversion
run: echo "::set-output name=version::$(grep version galaxy.yml | sed -e 's:^.* ::')"
- run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"
- run: "echo \"ARTIFACT_TAG=${GITHUB_REF#refs/tags/v}\" >> $GITHUB_ENV"

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
Expand All @@ -73,20 +60,24 @@ jobs:
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-${{ steps.cversion.outputs.version }}.tar.gz
_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-${{ steps.cversion.outputs.version }}.tar.gz --api-key ${{ secrets.GALAXY_API_KEY }}
run: ansible-galaxy collection publish blinklabs-cardano-${{ env.ARTIFACT_TAG }}.tar.gz --api-key ${{ secrets.GALAXY_API_KEY }}

finalize-release:
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace: blinklabs
name: cardano
version: 0.2.2
# NOTE: this is automatically replaced on publish
version: 0.0.0
readme: README.md
authors:
- Aurora Gaffney <[email protected]>
Expand Down

0 comments on commit efd1d85

Please sign in to comment.