ci(dev): attempt recreate tag ci #19
Workflow file for this run
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
name: Development Release CLI | |
on: | |
push: | |
branches: ["development"] | |
jobs: | |
build: | |
name: Release binary | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
artifact_name: dar2oar | |
asset_name: dar2oar-x86_64-unknown-linux-gnu.tar.gz | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
artifact_name: dar2oar | |
asset_name: dar2oar-x86_64-unknown-linux-musl.tar.gz | |
- os: ubuntu-latest | |
target: x86_64-pc-windows-gnu | |
artifact_name: dar2oar.exe | |
asset_name: dar2oar-x86_64-pc-windows-gnu.zip | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
artifact_name: dar2oar | |
asset_name: dar2oar-x86_64-apple-darwin.zip | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Without it, once created, the commit sha for the tag will not be updated. | |
- name: Recreate tag | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const refName = 'refs/tags/development'; | |
try { | |
// Check if the tag exists | |
const existingRef = await github.rest.git.getRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: refName | |
}); | |
// If the tag exists, delete it | |
await github.rest.git.deleteRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: refName | |
}); | |
console.log(`Deleted existing tag ${refName}`); | |
} catch (error) { | |
// Ignore errors if the tag does not exist | |
console.log(`Tag ${refName} does not exist. Proceeding to create it.`); | |
} | |
// Create the new tag | |
await github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: refName, | |
sha: context.sha, | |
message: 'Tagging commit for development' | |
}); | |
console.log(`Created tag ${refName}`); | |
- name: Install stable toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
- name: Cross build with all features | |
uses: actions-rs/cargo@v1 | |
with: | |
use-cross: true | |
command: build | |
args: --release --target ${{ matrix.target }} --all-features --verbose | |
- name: "Build Changelog" | |
id: changelog | |
uses: mikepenz/[email protected] | |
with: | |
commitMode: true | |
if: matrix.target == 'x86_64-pc-windows-gnu' | |
- name: Compress binary | |
run: | | |
if [[ "${{ matrix.target }}" == *"linux"* ]]; then | |
tar -czf ${{ matrix.asset_name }} target/${{ matrix.target }}/release/${{ matrix.artifact_name }} | |
else | |
zip -r ${{ matrix.asset_name }} target/${{ matrix.target }}/release/${{ matrix.artifact_name }} | |
fi | |
- name: Upload binaries to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
release_name: DAR to OAR Converter Development-${{ github.sha }} | |
body: ${{ steps.changelog.outputs.changelog }} | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ${{ matrix.asset_name }} | |
asset_name: ${{ matrix.asset_name }} | |
tag: "development" | |
prerelease: true | |
overwrite: true |