merge to release (#180) #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run CMake build on Windows and Linux | |
name: Create Release | |
on: | |
push: | |
branches: [ "release" ] | |
permissions: | |
contents: read | |
env: | |
ARTIFACTS_DIR: ${{ github.workspace }}/artifacts | |
ARTIFACTS_DIR_WIN: ${{ github.workspace }}\artifacts | |
jobs: | |
release: | |
# only on pushes to the release branch | |
name: Create Release | |
#needs: build | |
if: ${{ (github.ref_name == 'release') && github.event_name == 'push' }} | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
# download the artifacts | |
- name: "Download artifacts" | |
uses: "actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935" # v4.1.1 | |
with: | |
path: ${{ github.workspace }}/artifacts | |
- name: Rename Artifacts | |
run: | | |
mv ${{ github.workspace }}/artifacts/ubuntu-22.04-artifacts/artifacts-ubuntu-22.04.zip ${{ github.workspace }}/artifacts/OdbDesign-Linux-x64.zip | |
mv ${{ github.workspace }}/artifacts/windows-2022-artifacts/artifacts-windows-2022.zip ${{ github.workspace }}/artifacts/OdbDesign-Windows-x64.zip | |
mv ${{ github.workspace }}/artifacts/macos-12-artifacts/artifacts-macos-12.zip ${{ github.workspace }}/artifacts/OdbDesign-MacOS-x64.zip | |
- name: Generate SHA256 Sums | |
run: | | |
# sha256 | |
cd ${{ github.workspace }}/artifacts | |
sha256sum OdbDesign-Linux-x64.zip > OdbDesign-Linux-x64.zip.sha256sum | |
sha256sum OdbDesign-Windows-x64.zip > OdbDesign-Windows-x64.zip.sha256sum | |
sha256sum OdbDesign-MacOS-x64.zip > OdbDesign-MacOS-x64.zip.sha256sum | |
- name: Import GPG Key | |
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0 | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.PASSPHRASE }} | |
- name: Sign Binaries | |
run: | | |
cd ${{ github.workspace }}/artifacts | |
gpg --batch --yes --detach-sign --armor OdbDesign-Linux-x64.zip | |
gpg --batch --yes --detach-sign --armor OdbDesign-Windows-x64.zip | |
gpg --batch --yes --detach-sign --armor OdbDesign-MacOS-x64.zip | |
- name: Create Release Variables | |
run: | | |
export RELEASE_VERSION="${{vars.RELEASE_VERSION_PREFIX}}.${{github.run_number}}" | |
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV | |
export RELEASE_TAG="v${RELEASE_VERSION}" | |
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV | |
export RELEASE_NAME="OdbDesign ${RELEASE_TAG}" | |
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV | |
# create a release | |
- name: "Create GitHub Release" | |
uses: "actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea" # v7.0.1 | |
with: | |
github-token: "${{ secrets.GITHUB_TOKEN }}" | |
script: | | |
try { | |
const createResponse = await github.rest.repos.createRelease({ | |
generate_release_notes: true, | |
name: process.env.RELEASE_NAME, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
tag_name: process.env.RELEASE_TAG, | |
body: require('fs').readFileSync('${{ github.workspace }}/release/release-body.md', 'utf8'), | |
target_commitish: '${{ github.ref_name }}' | |
}); | |
const files = | |
[ | |
{ name: 'OdbDesign-Linux-x64.zip', contentType: 'application/zip' }, | |
{ name: 'OdbDesign-Linux-x64.zip.sha256sum', contentType: 'text/plain' }, | |
{ name: 'OdbDesign-Linux-x64.zip.asc', contentType: 'text/plain' }, | |
{ name: 'OdbDesign-Windows-x64.zip', contentType: 'application/zip' }, | |
{ name: 'OdbDesign-Windows-x64.zip.sha256sum', contentType: 'text/plain' }, | |
{ name: 'OdbDesign-Windows-x64.zip.asc', contentType: 'text/plain' }, | |
{ name: 'OdbDesign-MacOS-x64.zip', contentType: 'application/zip' }, | |
{ name: 'OdbDesign-MacOS-x64.zip.sha256sum', contentType: 'text/plain' }, | |
{ name: 'OdbDesign-MacOS-x64.zip.asc', contentType: 'text/plain' } | |
]; | |
const artifactsPath = '${{ github.workspace }}/artifacts'; | |
for (const file of files) { | |
const filePath = artifactsPath +'/' + file.name; | |
const uploadResponse = await github.rest.repos.uploadReleaseAsset({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: createResponse.data.id, | |
name: file.name, | |
data: require('fs').readFileSync(filePath), | |
headers: { | |
'content-type': file.contentType, | |
'content-length': require('fs').statSync(filePath).size | |
} | |
}); | |
} | |
} catch (error) { | |
core.setFailed(error.message); | |
} |